getting a deadlock with a JOGL context

Hi,

I’m getting a bit of a funny deadlock issue with an application I’m building which uses JOGL together with Swing and AWT.

I have a class which extends Thread which is my repaint Thread. It has an ArrayList of JFrames (including the frame with the JOGL canvas in it) and another ArrayList of classes extending from an extension of JFrame used for all my Swing/AWT frames. There is a synchronized add() method to each arraylist, and the run() method periodically calls a synchronized private method which calls repaint() on all the panels and display() on the GL canvas (the rest of the run loop is not synchronized). I’m not using an Animator class.

This all works fine until the user presses a button which causes the Event Dispatch Thread to call the add() method on the extended JFrames arraylist, when it deadlocks. If I profile the app, I can see that it is the Event Dispatch Thread that is waiting on the monitor, and never seems to get into the add() method.

Removing the ‘synchronized’ from either the add() method or the repaint block lets the programme run, but I’ve solved it a bit more robustly by wrapping the call to GLCanvas.display() in a SwingUtilities.invokeLater(new Runnable(){}); block (ie call it from the Event Dispatch Thread after the event queue is cleared).

Just wondering if anyone can shed light on why this is doing it, and whether my solution is a good one ? Does the GLCanvas.display() method keep the monitor on the object calling it somehow, even after it’s returned ?

Cheers

Please state the JOGL version you are using, thanks.

Just tested something remote similar with the JOGL2 branch,
it works fine. Even though I wasn’t using a seperate rendering thread.

It may also help to offer a proper simple test case.
But please test with the JOGL2 branch - thanks.
The old JOGL is running out of life - EOL soon.

If it is running out of line, give us a stable release of JOGL 2 and explain to us the modifications that have to be done to support it.

version 1.3, from the current release build on the JOGL website,

jogl-1.1.1-windows-i586.zip
Draft kbr on Thursday, May 22, 2008 at 11:54:58 PM JSR-231 1.1.1 binaries for Windows/x86

Hadn’t heard of JOGL 2 - where can I get the binaries from, is there a stable release build, and is it (hopefully) backward-compatible ?

Cheers,

Stu

Almost backward compatible … the changes are pretty intuitive.

Look at the new JOGL2 announcement.