JOGL seems to stall JVM without System.exit()

Cheers,

These forums are great. The app I am working on currently doesn’t use System.exit() to exit. Instead I am creating the AWT event queue on a daemon thread and exiting occurs when all non daemon threads are finished. See: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html

It seems that when a GLCanvas is added to any frame regardless if that frame is disposed of properly then the JVM (1.4.2_03 Win32) will hang.

I’ve created a test class similar to how my app works to show what is happening and would like to receive any input or ideas on what is going on. Commenting out the line that adds the GLCanvas will make this test code not stall the JVM.

This is my first time writing an app that exits in this manner, but I think I got it right. It works in all other cases thus far (even with dangling JDialog hidden frames, etc.). Any help is appreciated.

A bundle with the class and JOGL version I’m using (Sept binary) is available here:
http://audio.egregious.net/scream/jogltest.rar (500k)

Here is the test class though:


import net.java.games.jogl.*;
import javax.swing.*;
import java.awt.*;

public class JOGLTest extends Thread
{
   public static void main(String[] args)
   {
      JOGLTest test = new JOGLTest();
      test.start();
      try { test.join(); } catch(InterruptedException e) {}

      // Some JVMs will leave zombie frames/dialogs open even if they were disposed; Explicitly disposing of all
      // remaining frames will allow the JVM to quit; uh except for this JOGL problem?
      Frame frames[] = Frame.getFrames();
      for (int cntr = frames.length - 1; cntr >= 0; cntr--)
         if (frames[cntr] != null)
            frames[cntr].dispose();
   }

   public JOGLTest()
   {
      super();
      setDaemon(true);
   }

   public void run()
   {
      JFrame frame = new JFrame();
      frame.getContentPane().setLayout(new BorderLayout());

      GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());

// Comment out adding the GLCanvas and this demo will not stall after clicking ok on the dialog
/////////////////////////////////////////////////////////////////////////////////////////
      frame.getContentPane().add(canvas, BorderLayout.CENTER);
/////////////////////////////////////////////////////////////////////////////////////////

      frame.pack();
      frame.setVisible(true);

      JFrame dialog;
      JOptionPane.showMessageDialog(dialog = new JFrame(), "Why does it stall?");
      dialog.dispose();

      frame.setVisible(false);
      frame.removeAll();
      frame.dispose();
   }
}


About my projects: I’m working on an interesting one called Scream that will bring very new and exciting audio features to Java. I am creating an optimized API to work with real time audio engines such as SuperCollider3 (or any other audio engine that supports OSC networking protocol). I’m creating the API to make music software, however it will be very relevant to the gaming / simulation arena (physics sound+) and also eventually creating audio tools for film/video post production. Info on Scream can be found here: http://audio.egregious.net/scream/

I’ll be presenting at CodeCon next month and will hopefully have a 3D gaming demo complete where most of the audio is real time generated (not recorded). I’m using b-format ambisonics which can be scaled to an n-speaker arrangement; hopefully I’ll have 6 at Codecon. Lots of bullets flying through the air… :stuck_out_tongue_winking_eye: check out some of the pictures on the scream page for an idea of the music related tools I’m making though.

Best,
–Mike

That code works just fine with jre1.5 but you didn’t hear that from me.

This is a hotly debated bug in a variety of circles. Rest assured that unless sun does something stupid - you won’t have to put a bullet through your application to make it die when JDK1.5 comes out.

Excellent to hear. I won’t be publically deploying my app until post JDK1.5 and will be requiring its usage, so waiting this one out is fine. Thanks for the head check… :smiley: