Login  Register

Re: JVM Crash During X11 Shutdown

Posted by rhatcher on Sep 21, 2012; 2:15pm
URL: https://forum.jogamp.org/JVM-Crash-During-X11-Shutdown-tp4026218p4026233.html

Sven wrote:
> We are talking about AWT, I see :)

Heh.  Yeah - it's a decade-old pile of legacy goo.  We currently are working on replacing our Swing/AWT UIs with E4/SWT, mostly to get the nice real-estate management features.  And we are an Eclipse shop so there's some synergy there.

In the meantime I'm primarily interested in figuring out the pattern/recipe required in Swing/AWT apps to guarantee clean shut-down through all possible normal exit scenarios (X button, ALT+F4 (same thing I guess), or File-Quit handler, or ESC key, or whatever).  Then I can go fix all affected spots in the interests of stopping further propagation of the wrong approach through the copy/paste/modify "reuse technique".


> 1) Don't do it in another thread @ windowClosing, it's too late
> 2) Don't call System.exit(0) ..

I borrowed both of these from the JGears demo (copy/paste/modify strikes again).  Not all of the demos do these things, but many do.

I only ran the JGears demo, but I also poked around in the other demo code and on inspection got the impression that a majority may not be handling shutdown/cleanup correctly (?).  I could be totally off the mark about this because I didn't have time to run all of them.

In the jogl-demos I cloned yesterday there are 108 demo classes that appear to create JFrames, so checking them all, fixing the offenders, and doing the testing would take a chunk of time.


>  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Swing JFrame only (I guess)
>
> // close nicely w/ GLCanvas destruction
> addWindowListener(new WindowAdapter() {
>   public void windowClosing(WindowEvent e) {
>     getContentPane().remove(fCanvas); // Swing JFrame !
>     remove(fCanvas); // AWT Frame !
>   }
> });

Tweeking my test app to add your suggestions above also shut down cleanly, so I'll proceed with that.  Though... there is still the issue of whether or not to call System.exit based on Julien's comment.

I'll keep an ear on this topic for further wisdom.