aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-01-28 02:43:29 +0000
committerKenneth Russel <[email protected]>2005-01-28 02:43:29 +0000
commit0e0957380a24ea02bdcb3ae652b9367d505345f2 (patch)
treea3be0da5ca1d91e1f88ac38f4b4ba05a500c2513 /src/net/java/games/jogl/impl
parent5b5b8fe543ec1e4189db1c9de4cea8755a2e3ddc (diff)
Fixed Issue 54: No GL listener callbacks when setting render thread before window is visible
The issue (or a related one) is still present in the current JOGL build, although the symptom was different: a deadlock upon startup of the application. When the OpenGL context is created in the WindowsOnscreenGLContext implementation, it causes Component.getGraphicsConfiguration() to be called, which causes the AWT tree lock to be grabbed. Under some circumstances, another thread can already hold the AWT tree lock and call GLContext.invokeGL(), which leads to a classic deadlock. Resolved this by eagerly grabbing the tree lock under some circumstances (not all the time) before entering the synchronized invokeGL in (only) the Windows onscreen context implementation. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@193 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl')
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
index 3bfdee5d1..1838f62aa 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
@@ -61,6 +61,25 @@ public class WindowsOnscreenGLContext extends WindowsGLContext {
super(component, capabilities, chooser, shareWith);
}
+ public void invokeGL(Runnable runnable, boolean isReshape, Runnable initAction) throws GLException {
+ // Unfortunately, invokeGL can be called with the AWT tree lock
+ // held, and the Windows onscreen implementation of
+ // choosePixelFormatAndCreateContext calls
+ // Component.getGraphicsConfiguration(), which grabs the tree
+ // lock. To avoid deadlock we have to lock the tree lock before
+ // grabbing the GLContext's lock if we're going to create an
+ // OpenGL context during this call. This code might not be
+ // completely correct, and we might need to uniformly grab the AWT
+ // tree lock, which might become a performance issue...
+ if (hglrc == 0) {
+ synchronized(component.getTreeLock()) {
+ super.invokeGL(runnable, isReshape, initAction);
+ }
+ } else {
+ super.invokeGL(runnable, isReshape, initAction);
+ }
+ }
+
protected GL createGL()
{
return new WindowsGLImpl(this);