Animator.stop doesn't block on AWT thread?? Why?

Hi,

The JavaDoc for JOGL says that Animation.stop will perform blocking until the animator is finished.

Um… no it doesn’t.

The animator.stop method returns if the current thread is the dispatch thread from AWT.

Look at the following case:

animator.stop();
animator.start();

The second call will cause a JOGL exception saying that the animator is already running. Except, it won’t be running for long. Cause the pending stop is still going to happen.

So in my application we stop the animator, clear the 3D scene, load some data from a file, and then call start. Except it doesn’t start up again? Think’s it’s still running, but it’s going to stop.

So I’m unable to start it again.

Having Animator.stop() block on the AWT thread can lead to deadlocks in particular with the GLJPanel where all work is done on the AWT event queue thread. There is no easy way (as far as I can tell) to determine whether blocking in stop() will cause a deadlock.
This is the fundamental reason why Animator.stop() was changed to return immediately if called from the AWT event queue thread.

A couple of comments. First, if you want to maintain interactivity in your application while loading a large model file then you shouldn’t be doing that work on the AWT event queue thread (or inside your GLEventListener), but should instead spawn a worker thread which will hand off its results when the loading is completed. Second, it isn’t clear to me why you need to stop and restart the Animator at all. All it really does is drive the display loop and assuming you have appropriate synchronization in your application you should be able to just swap in the new scene without touching the Animator.

Hi Ken,

Thanks once again for providing clear and understandable answers. :slight_smile:

I think the problem is we’re using the animator class out of context, and will write a new one. Which will leave the thread running, but give us the ability to pause the while loop that calls display.

Since calling start and stop causes the thread to be destroyed, and created. This is clearly not the correct solution.

If would make a nice feature for JOGL if the animator had a pause() method.