FULL PRODUCT VERSION :
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
$ uname -a
Linux cello 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:54:58 UTC 2017 i686 i686 i686 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
EXTRA RELEVANT SYSTEM CONFIGURATION :
The Ubuntu OS is running in a VMware Fusion Professional Version 8.5.8 virtual machine.
A DESCRIPTION OF THE PROBLEM :
With a Java Swing application running, changing the resolution of the display with xrandr results in an exception trace being written to the standard error stream of the Java Swing application, and the Java Swing application's frame goes blank.
An 18 second screen video showing the problem is here:
https://www.imca.aps.anl.gov/~jlmuir/tmp/BufImgSurfaceDataTest.mp4
I am also able to reproduce this problem on RHEL (Red Hat Enterprise Linux) 7.3 inside a NoMachine 3.5.9 NX session by simply resizing the NX client window by dragging the bottom right corner around. On this RHEL 7.3 system, the Java version is as follows:
$ java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
I am aware of the following bug reports, but they are either not the same issue or have not been fixed in the Java VM I have (which is the latest from Canonical for my OS as of this writing):
* https://bugs.openjdk.java.net/browse/JDK-8147542
* https://bugs.openjdk.java.net/browse/JDK-8133723
* https://bugs.openjdk.java.net/browse/JDK-8160328
* https://bugs.openjdk.java.net/browse/JDK-8164540
* https://bugs.openjdk.java.net/browse/JDK-7172749
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the provided test-case application:
$ javac BufImgSurfaceDataTest.java
$ java BufImgSurfaceDataTest
2. List the display's current resolution (marked with '*') and choices:
$ xrandr
3. Change the display resolution to one of the choices; in this example, the output is named Virtual1, the current resolution is 1600x1200, and it will be changed to 1680x1050:
$ xrandr --output Virtual1 --mode 1680x1050
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the Java application to continue running normally, displaying the dark gray circle, and having no exception trace written to its standard error stream.
ACTUAL -
The Java application's frame went blank (light gray and no dark gray circle), and an exception trace was written to its standard error stream. The exception trace is noted in the "Error Message(s)/ Crash Logs" section.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData
at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:148)
at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:356)
at sun.java2d.SurfaceDataProxy.updateSurfaceData(SurfaceDataProxy.java:498)
at sun.java2d.SurfaceDataProxy.replaceData(SurfaceDataProxy.java:455)
at sun.java2d.SurfaceData.getSourceSurfaceData(SurfaceData.java:233)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:566)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296)
at javax.swing.ImageIcon.paintIcon(ImageIcon.java:425)
at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:167)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at javax.swing.JComponent.paintComponent(JComponent.java:780)
at javax.swing.JComponent.paint(JComponent.java:1056)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5217)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290)
at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
at javax.swing.JComponent.paint(JComponent.java:1042)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)
at java.awt.Container.paint(Container.java:1975)
at java.awt.Window.paint(Window.java:3904)
at javax.swing.RepaintManager$4.run(RepaintManager.java:842)
at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class BufImgSurfaceDataTest {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(BufImgSurfaceDataTest::createAndShowGui);
}
private static void createAndShowGui() {
JFrame frame = new JFrame(BufImgSurfaceDataTest.class.getName());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JLabel(circleIcon()), BorderLayout.CENTER);
frame.pack();
Dimension d = frame.getSize();
frame.setSize(Math.max(d.width, 400), Math.max(d.height, 300));
frame.setVisible(true);
}
private static ImageIcon circleIcon() {
BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setColor(Color.DARK_GRAY);
g.fillOval(0, 0, image.getWidth(), image.getHeight());
return new ImageIcon(image);
}
}
---------- END SOURCE ----------