-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b85
-
generic
-
generic
The sun.applet.AppletPanel class is performing illegal AWT operations internally upon applet termination. The general rule is that once a component hierarchy is visible, all operations on the components should be performed on the Event Dispatch Thread using EventQueue.invokeAndWait() / invokeLater() for correctness. The AppletPanel is performing remove() calls on its own thread rather than handing this work off to the EDT to be done there. This causes deadlocks with applets which attempt to be smart about doing all of their work on the EDT.
The attached jstack output shows a deadlock that occurs with the open-source JOGL library (http://jogl.dev.java.net/) in conjunction with applets. AppletPanel calls remove() which ends up calling GLCanvas.removeNotify(). The implementation of this method detects that it is not on the EDT and attempts to perform its OpenGL-related work on the EDT to mitigate driver-level issues. Because the current thread holds the AWT tree lock (by virtue of having called remove() directly rather than performing the remove() call on the EDT) the fact that this thread blocks waiting for the EDT to execute a Runnable causes a deadlock as soon as the EDT attempts to acquire the tree lock.
This bug should be fixed by changing the AppletPanel to perform its remove() call using EventQueue.invokeAndWait(). In the interim we have worked around this bug in the JOGL library by causing it to detect the deadlock situation and perform the associated OpenGL work on the current thread, which is not the best behavior but is better than deadlocking the JVM.
The attached jstack output shows a deadlock that occurs with the open-source JOGL library (http://jogl.dev.java.net/) in conjunction with applets. AppletPanel calls remove() which ends up calling GLCanvas.removeNotify(). The implementation of this method detects that it is not on the EDT and attempts to perform its OpenGL-related work on the EDT to mitigate driver-level issues. Because the current thread holds the AWT tree lock (by virtue of having called remove() directly rather than performing the remove() call on the EDT) the fact that this thread blocks waiting for the EDT to execute a Runnable causes a deadlock as soon as the EDT attempts to acquire the tree lock.
This bug should be fixed by changing the AppletPanel to perform its remove() call using EventQueue.invokeAndWait(). In the interim we have worked around this bug in the JOGL library by causing it to detect the deadlock situation and perform the associated OpenGL work on the current thread, which is not the best behavior but is better than deadlocking the JVM.