JDK-6652531 : D3D: intermittent NPE when ALT+Tabing a FS frame rendering a volatile image, WinVista
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2008-01-18
  • Updated: 2020-10-25
  • Resolved: 2020-10-25
Related Reports
Duplicate :  
Relates :  
Description
I am running a FullScreen application which screen-captures the desktop and renders it within a volatile image. The volatile image is actually scaled and rotated continuously driven by a timer and the volatile image is rendered onto the graphics context of a JComponent. The application has it's own rendering loop which keeps the image scaled and rotated.

When the FS frame appears, I am trying to ALT+TAB or press the 'Windows' key a few times. After 3-4 trials, I am getting an exception on the console. This happens consistantly in less than 5 trials on my laptop installed with Windows Vista Home Premium (Aero enabled) - Nvidia GeForce 8400M. I reproduced it with 6u10-b11 PIT build and b09 promoted build. The same test goes into an infinite loop on b10 because of another issue.

Here is the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: HDC for component
at sun.java2d.loops.ScaledBlit.Scale(Native Method)
at sun.java2d.pipe.DrawImage.scaleSurfaceData(DrawImage.java:956)
at sun.java2d.pipe.DrawImage.renderImageScale(DrawImage.java:611)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:97)
at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1018)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2943)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2894)
at BufferTestSwingVolatile.render(BufferTestSwingVolatile.java:98)
at BufferTestSwingVolatile.paintUI(BufferTestSwingVolatile.java:38)
at BufferTestSwingVolatile.actionPerformed(BufferTestSwingVolatile.java:32)
at javax.swing.Timer.fireActionPerformed(Timer.java:271)
at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:284)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

I have attached the sample test herewith. Run the test and just press ALT+TAB/Windows key a few times to see the exception.

Comments
EVALUATION The NPE is thrown from GDIWinSD_Lock method when we fail to get the HDC for the screen: hDC = wsdo->GetDC(env, wsdo, 0, NULL, NULL, NULL, 0); if (hDC == NULL) { wsdo->surfaceLock->Leave(); if (beingShutdown != JNI_TRUE) { JNU_ThrowNullPointerException(env, "HDC for component"); } return SD_FAILURE; } Since this code is part of the GDI pipeline I think given enough time one can reproduce it even with the d3d pipeline disabled. This is likely a race condition of some sort. One way to "address" this would be not to throw unrecoverable NPE but InvalidPipeException so that the surface will be replaced. It would be better, of course, to get to the bottom of the race condition.
18-01-2008