JDK-8160328 : ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData after xrandr change output
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2016-06-26
  • Updated: 2016-07-22
  • Resolved: 2016-07-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_112-ea"
Java(TM) SE Runtime Environment (build 1.8.0_112-ea-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
3.19.0-61-generic #69~14.04.1-Ubuntu SMP Thu Jun 9 09:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
Intel Graphics Card:

00:02.0 VGA compatible controller: Intel Corporation Sky Lake Integrated Graphics (rev 0a) (prog-if 00 [VGA controller])
	Subsystem: Dell Device 0704
	Flags: bus master, fast devsel, latency 0, IRQ 130
	Memory at db000000 (64-bit, non-prefetchable) [size=16M]
	Memory at 90000000 (64-bit, prefetchable) [size=256M]
	I/O ports at f000 [size=64]
	Expansion ROM at <unassigned> [disabled]
	Capabilities: <access denied>
	Kernel driver in use: i915_bpo

A DESCRIPTION OF THE PROBLEM :
I'm running jEdit (http://www.jedit.org/). After switching the monitor, I see that the jedit window is not painted anymore.  In the console I see a stacktrace of ClassCastException in sun.java2d.xr.XRPMBlitLoops.
It seems that partial repaints are working, e.g. if I scroll the text pane, it is redrawn.

There is a workaround - disable the Xrender pipeline. Then there are no problems/exceptions after switching the output.




REGRESSION.  Last worked in version 7u80

ADDITIONAL REGRESSION INFORMATION: 
I didn't actually test it with java 7, but I don't remember having seen this. And as far as I figured out, the xrender pipeline was disabled by default in java7.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start jEdit
2. Change display output: Switch the displays (turn the internal display off, turn the external monitor on). I doesn't happen in clone mode. E.g. using xrandr: xrandr --output eDP1 --auto --output DVI-1-0 --off



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The jEdit window doesn't change.
ACTUAL -
The jEdit window just shows a gray rectangle. No menu, no text pane.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0: Exception in thread "AWT-EventQueue-0" 
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0: java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:145)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:353)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SurfaceDataProxy.updateSurfaceData(SurfaceDataProxy.java:498)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SurfaceDataProxy.replaceData(SurfaceDataProxy.java:455)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SurfaceData.getSourceSurfaceData(SurfaceData.java:233)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:566)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.awt.image.ImageRepresentation.drawToBufImage(ImageRepresentation.java:813)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1021)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.ImageIcon.paintIcon(ImageIcon.java:425)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:167)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintComponent(JComponent.java:780)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at org.gjt.sp.jedit.browser.FileCellRenderer.paintComponent(FileCellRenderer.java:144)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1056)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.CellRendererPane.paintComponent(CellRendererPane.java:151)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2115)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2016)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1812)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintComponent(JComponent.java:780)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1056)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JViewport.paint(JViewport.java:728)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at org.gjt.sp.jedit.gui.DockableWindowManagerImpl.paintChildren(DockableWindowManagerImpl.java:672)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintChildren(JComponent.java:889)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paint(JComponent.java:1065)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager$4.run(RepaintManager.java:854)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.security.AccessController.doPrivileged(Native Method)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventQueue.access$500(EventQueue.java:97)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventQueue$3.run(EventQueue.java:709)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventQueue$3.run(EventQueue.java:703)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.security.AccessController.doPrivileged(Native Method)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
21:17:51 [AWT-EventQueue-0] [error] AWT-EventQueue-0:  at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


REPRODUCIBILITY :
This bug can be reproduced often.

CUSTOMER SUBMITTED WORKAROUND :
Disable the xrender output via: -Dsun.java2d.xrender=false



Comments
It should be reproducible right from 8 GA.
08-07-2016

Does it affect 8u102? Is it a regression in 8u112?
04-07-2016

Info from submitter: The bug is reproducible with JDK 9 b124 and the bug doesn't appear with jdk7u80.
04-07-2016

The Xrender code assumes that the VolatileImage surface will be an XRSurfaceData but in the event that could not be created it will be a BufImageSurfaceData. There seems to be a chain of assumptions in Xrender here that it will be its subclass of SurfaceData. The fix may be to do similar to what is done in https://bugs.openjdk.java.net/browse/JDK-7172749 and throw InvalidPipeException since after the monitor we may need to reinitialise.
27-06-2016

JDK-8133723 may not be a duplicate of JDK-7172749. JDK-7172749 is fixed in 9 b124 and 8u112 b01. Submitter of this bug added a detailed observation at http://stackoverflow.com/a/38038737/1169968
27-06-2016