We are having many issues with jogl1.1b10. They are to do with the new threading model. Our rendering engine uses a single rendering thread to make calls to OpenGL. It manages both asynchronous and synchronous calls to OpenGL. It was working just fine with the old threading model!
When picking and printing we really need calls to OpenGL to occur synchronously. The new threading model makes this very difficult, resulting in immediate deadlock.
For example, if a pick is initiated from a mouse click, via the AWT event queue thread (AWT-EventQueue-0) it requests our rendering thread to perform the operation. We synchronize the AWT-EventQueue-0 thread with our rendering thread using wait, thus the AWT-EventQueue-0 thread issues a wait, which it is only released once the rendering thread has completed.
It is our rendering thread that interacts with the GLCanvas. It calls GLCanvas.display to get the rendering [picking] under way. This is when the deadlock occurs. GLCanavas.maybeDoSingleThreadedWorkaround calls EventQueue.invokeAndWait which blocks because AWT-EventQueue-0 is already waiting on our rendering thread!
Here is the call stack from the two threads:
Our Rendering Thread
wait() : 429, java.lang.Object
invokeAndWait() : 829, java.awt.EventQueue
maybeDoSingleThreadedWorkaround() : 220, net.java.games.jogl.GLCanvas
display() : 75, net.java.games.jogl.GLCanvas
…
AWT-EventQueue-0 Thread
wait() : 429, java.lang.Object
…
Synchronize with rendering thread
…
processMouseEvent() : 5100, java.awt.Component
…
I think that this scenario could be quite common amongst JOGL users; the current fix in jogl1.1b10 does not work well in such cases.
Currently the only way to revert JOGL back to the old method of rendering is via setting the property “jogl.1thread”, something like a static class initializer:
static
{
try
{
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
System.setProperty("jogl.1thread", "false");
return null;
}
});
}
catch (Throwable e)
{
/* Exception handling goes here */
}
}
This works but since it requires privileges it means our jar file needs signing, something we would really rather not have to do. Is there another programmatic way, which does not require privileges, to force GLCanvas to render using the old method?
Any comments/suggestions? Thanks in advance
Alan Michael Gay