JDK-8185960 : ClassCastException (BufImgSurfaceData cannot be cast to XRSurfaceData) on resolution change
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u131
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2017-08-02
  • Updated: 2017-08-11
  • Resolved: 2017-08-08
Related Reports
Duplicate :  
Description
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 ----------


Comments
Additional Information shared by the submitter: =================================== The minimal test application referenced in bug 8147542 (which refers to the minimal test application in bug 8147016) will only work on Java 9 because it uses BaseMultiResolutionImage which does not exist in Java 8. So, I had no easy way to confirm that the same problem existed in Java 8. If they are the same bug, then I would expect that my minimal test application will also reproduce the issue in Java 9, but I haven't tried it. If mine does reproduce the issue in 9, then mine might be a little more useful because the same minimal test application could be used in both 8 and 9. Tried with a CentOS 7 guest inside a VirtualBox 5.1.26 VM, and was *unable* to reproduce it! After trying lots of things, I finally discovered that it fails when the desktop environment is Xfce!! On CentOS 7, using the GNOME desktop environment, my minimal test application does *not* reproduce the problem, just like you experienced. On CentOS 7, to install and run Xfce 4.12, I did the following: $ sudo yum groups install Xfce $ echo 'exec /usr/bin/xfce4-session' > ~/.xinitrc $ startx Performing the steps to reproduce the issue from the above Xfce desktop environment in a VirtualBox 5.1.26 VM *does* reproduce the issue. On Ubuntu 16.04.3 LTS, I had previously done the following to install Xfce and run it: 1. $ sudo aptitude install xfce4 2. Log out. 3. Click the icon next to the login textfield of the login manager and choose "Xfce Session". 4. Log in.
11-08-2017

Submitter says " I am aware of the following bug reports, ... or have not been fixed in the Java VM I have" So submitter is on 8uX. The bug is only fixed in 9. Ergo this is a duplicate bug report. Re-reporting it against 8ux is not how it gets fixed in 8ux. It should go through support channels.
08-08-2017

According to submitter changing the resolution of the display with xrandr while running a Java Swing application 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. This issue is reported with Ubuntu 16.0.4.3 LTS (Running in a VMware Fusion Professional Version 8.5.8 virtual machine). To verify perform the below steps: 1. Compile and run the attached test case. $ 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 Checked this for JDK 8u131, 8u141, 8u144 as well as 9 ea b180 on Ubuntu 16.04.3 running as a virtual machine inside Oracle Virtual box and, could not reproduce the issue. However, submitter confirms that the issue is reproducible with RHEL and JDK 8u141 as well. Attached is a video demonstrating steps to reproduce and results.
08-08-2017