Removing NewtSwingGlimpseCanvas from its parent causes native crash

38 views
Skip to first unread message

Mike Hogye

unread,
Dec 11, 2013, 5:15:41 PM12/11/13
to metsci-...@googlegroups.com
When I try to remove a NewtSwingGlimpseCanvas from its container, I get a crash in native-land:

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libGL.so.1+0x820ec]  glXCreatePixmap+0xbbcc
C  0x00007fd5b86e7120

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jogamp.nativewindow.x11.X11Lib.XCloseDisplay(J)I+0
j  jogamp.nativewindow.x11.X11Util.XCloseDisplay(J)I+43
j  jogamp.nativewindow.x11.X11Util.closeDisplay(J)V+199
j  com.jogamp.nativewindow.x11.X11GraphicsDevice.close()Z+60
j  jogamp.newt.awt.NewtFactoryAWT.destroyNativeWindow(Lcom/jogamp/nativewindow/awt/JAWTWindow;)V+20
j  com.jogamp.newt.awt.NewtCanvasAWT.destroyImpl(ZZ)V+158
j  com.jogamp.newt.awt.NewtCanvasAWT.removeNotify()V+24
j  java.awt.Container.removeNotify()V+47
j  javax.swing.JComponent.removeNotify()V+1
j  java.awt.Container.removeNotify()V+47
j  javax.swing.JComponent.removeNotify()V+1
j  java.awt.Container.remove(I)V+55
j  java.awt.Container.remove(Ljava/awt/Component;)V+32
...

AFAICT this is a NEWT bug, and has nothing to do with Glimpse. Crash occurs with both JOGL 2.0 and 2.1. It’s particularly a problem for DockingPane, which removes and re-adds views to move them between tiles.

Mike Hogye

unread,
Dec 11, 2013, 5:19:20 PM12/11/13
to metsci-...@googlegroups.com
Well, I figured I would put together a code snippet to reproduce the problem, and submit it in a bug report. And I figured I would follow the same form as some of Sven’s unit tests, so I put all the frame setup (new JFrame, pack, setVisible, etc.) on the Swing thread (SwingUtilities.invokeLater) … and voila, no more crashy.

After a little more investigating, it looks like it’s the "parent.add(canvas)" that must be on the Swing thread. This works fine:

        GLWindow glWindow = GLWindow.create( new GLCapabilities( GLProfile.getDefault( ) ) );
        final NewtCanvasAWT canvas = new NewtCanvasAWT( glWindow );

        final JFrame frame = new JFrame( );
        frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
        frame.setPreferredSize( new Dimension( 800, 600 ) );
        frame.pack( );
        frame.setVisible( true );

        SwingUtilities.invokeAndWait( new Runnable( )
        {
            public void run( )
            {
                frame.getContentPane( ).add( canvas );
            }
        } );

        SwingUtilities.invokeAndWait( new Runnable( )
        {
            public void run( )
            {
                // Crashes unless add was called on Swing thread
                frame.getContentPane( ).remove( canvas );
            }
        } );

Geoffrey Ulman

unread,
Dec 11, 2013, 5:25:39 PM12/11/13
to metsci-...@googlegroups.com
It looks like it would be a good idea to make this change in the Glimpse Example class as well, since that's where most people will see it.
Reply all
Reply to author
Forward
0 new messages