JDK-6726667 : D3D: sun.java2d.InvalidPipeException is thrown when resizing JInternalFrame in a non-opaque JFrame
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: x86
  • Submitted: 2008-07-17
  • Updated: 2011-01-19
  • Resolved: 2008-09-23
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 6 JDK 7
6u10 b31Fixed 7Fixed
Related Reports
Relates :  
Relates :  
Description
Resizing a JInternalFrame in a non-opaque JFrame may lead to throwing the sun.java2d.InvalidPipeException. It also produces a visual garbage on the screen.
It is reproducible with 6u10b27 on Vista. 

EXCEPTION STACK TRACE:
****************************************************
Exception in thread "AWT-EventQueue-0" sun.java2d.InvalidPipeException: bounds c
hanged or surface lost
        at sun.java2d.pipe.BufferedContext.validate(Unknown Source)
        at sun.java2d.pipe.BufferedContext.validateContext(Unknown Source)
        at sun.java2d.pipe.BufferedContext.validateContext(Unknown Source)
        at sun.awt.windows.TranslucentWindowPainter$VIOptWindowPainter.update(Un
known Source)
        at sun.awt.windows.TranslucentWindowPainter.updateWindow(Unknown Source)

        at sun.awt.windows.WWindowPeer.updateWindow(Unknown Source)
        at java.awt.Window.updateWindow(Unknown Source)
        at java.awt.Window.access$900(Unknown Source)
        at java.awt.Window$1.updateWindow(Unknown Source)
        at javax.swing.RepaintManager.updateWindows(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknow
n Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source) 
****************************************************

TEST APPLICATION:
****************************************************
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.lang.reflect.*;

public class NonOpaqueWindowTest2 extends JFrame
{
  public NonOpaqueWindowTest2()
  {
    super();    
    setWindowNonOpaque(this);
    
    JDesktopPane desktop = new JDesktopPane();
    JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);
    iFrame.add(new JLabel("internal Frame"));
    iFrame.setBounds(10, 10, 300, 200);
    iFrame.setVisible(true);
    desktop.add(iFrame);    
    getContentPane().add(desktop);
    
    setTitle(getClass().getSimpleName());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);
    setLocationRelativeTo(null);
    setVisible(true);
  }
  
  private void setWindowNonOpaque(Window w)
  {
    try 
    {
      Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
      Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
      m.invoke(null, w, false);
    } 
    catch (Exception e) 
    {
      e.printStackTrace();
    }    
  }
 
  public static void main(String[] args) throws Exception
  {
    EventQueue.invokeLater(new Runnable(){
      public void run()
      {
        JFrame.setDefaultLookAndFeelDecorated(true);
        new NonOpaqueWindowTest2();
      }      
    });
  }  
}
****************************************************

STEPS TO REPRODUCE:
1. Run the application with 6u10b27 on Vista (I've verified it having Aero theme enabled).
2. Start resizing the internal frame with the mouse.
3. The exception stack trace is printed on the console.

The issue is reported here:
http://forums.java.net/jive/thread.jspa?threadID=43881&tstart=0

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/java2d_data/6u11/6726667.0
14-08-2008

EVALUATION Even though I can't reproduce the exception yet I can see how it could happen. When BufferedContext is validated it may throw an IPE which I was supposed to catch.
17-07-2008

EVALUATION Note that the exception can only occur with the D3D pipeline, but the painting artifacts are reproducible with the D3D pipeline disabled and I think may be cause dy some special painting code for internal frames - it coud be that our painting interception mechianism for non-opaque windows missing the updates when internal frame is dragged/resized. I believe the exception and the painting problems are two unrelated issues, so I'll file separate bug for painting problems. Also, I can't reproduce the exception on XP, it may be Vista specific.
17-07-2008