From d93c5d23e304ea20e868595748f92a5bef4f5703 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 28 Dec 2012 14:10:14 +0100 Subject: AWT GLCanvas: More strict GLDrawable realization [on AWT-EDT], skip if creation is not possible on AWT-EDT. The Intel HD3000 OpenGL driver on Windows will deadlock @ SwapBuffers in case the drawable is created on a thread other than the window owner thread. We are aware of such possibilities, nevertheless the AWTEDTExecutor.singleton.invoke(..) allowed to execute the runnable in case it cannot be invoked on AWT-EDT. The latter is the case if the current thread is not the AWT-EDT _and_ is holding the AWT tree-lock. With GlueGen commit 0b43b43f889ad7fc220942b0076e2001ca3cf13f, the invoke method now consumes an argument allowing to restrict the execution to AWT-EDT only. In such case, the drawable will be realized at a later time from the AWT-EDT. Such a situation could be triggered if a Frame's setVisible(true) is not issued from the AWT-EDT, as it should be! However, to relax such use cases - we better recognize such possible dealock and avoid it. --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/jogl/classes/javax/media') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index efdc69ed8..2f7fef9be 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -580,14 +580,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( Beans.isDesignTime() || !isDisplayable() || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { return false; // early out! } - // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); - final boolean res = _drawable.isRealized(); + // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock! + final boolean res0 = AWTEDTExecutor.singleton.invoke(getTreeLock(), false /* allowOnNonEDT */, true /* wait */, setRealizedOnEDTAction); + final boolean res1 = res0 && _drawable.isRealized(); if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+res+", "+_drawable.toString()); + System.err.println(getThreadName()+": Realized Drawable: invoked "+res0+", probedIsRealized "+res1+", "+_drawable.toString()); Thread.dumpStack(); } - return res; + return res1; } return false; } @@ -879,7 +879,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing ",\n\thandle 0x"+Long.toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ",\n\tvisible "+isVisible()+ + ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+ ",\n\t"+awtConfig+"]"; } @@ -949,7 +949,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing validateGLDrawable(); // immediate attempt to recreate the drawable } else { if(null != awtConfig) { - AWTEDTExecutor.singleton.invoke(getTreeLock(), true, disposeAbstractGraphicsDeviceActionOnEDT); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, disposeAbstractGraphicsDeviceActionOnEDT); } awtConfig=null; } -- cgit v1.2.3