Re: JVM Crash During X11 Shutdown
Posted by rhatcher on Sep 20, 2012; 10:25pm
URL: https://forum.jogamp.org/JVM-Crash-During-X11-Shutdown-tp4026218p4026230.html
This begs another question though:
I assume the shutdown responsibility of well-behaved JOGL graphics components is to implement "dispose" and make sure everything is cleaned up there, but the responsibility for calling dispose lies elsewhere.
I experimented with this some in a small test app and it looked like dispose won't get called unless either the frame containing the GLCanvas is disposed explicitly or the canvas itself is disposed explicitly (?). IOW unless I had a window listener like this:
private class TestWindowAdapter extends WindowAdapter
{
@Override
public void windowClosing( WindowEvent e )
{
new Thread( new Runnable() {
public void run() {
_animator.stop() ;
_graphicsFrame.dispose() ;
System.exit(0) ;
}
} ).start() ;
}
}
...and a File->Quit handler like this:
quitMenuItem.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent event ) {
new Thread( new Runnable() {
public void run() {
_animator.stop() ;
_graphicsFrame.dispose() ;
System.exit(0) ;
}
} ).start() ;
}
} ) ;
...i.e. that called _graphicsFrame.dispose() explicitly, then dispose() in my GLEventListener didn't get called, and I still got the crash.
So, even if the various listeners implement dispose() this cleanup is not exactly automatic and some careful setup is required to make sure it happens.
I ran the Gears/JGears demo and it crashed at shutdown too (and the Gears dispose method didn't get called) until I added an explicit dispose call on the frame.