From a94ff9252df66c303f48489c3e8926104941465c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 16 Feb 2013 03:55:22 +0100 Subject: Fix Bug 691 (part-3): NSOpenGLLayer::openGLContextForPixelFormat(..) on main-thread deadlock'ed due to locked shared context NSOpenGLLayer::openGLContextForPixelFormat(..) is performed on main-thread at 1st NSOpenGLLayer display method. This happened irregulary, i.e. sometimes (T0) right after NSOpenGLLayer creation and attachSurfaceLayer()/AddCASublayer(..), sometimes later (T1). NSOpenGLLayer::openGLContextForPixelFormat(..) uses the passed shared user context. The shared user context is locked at NSOpenGLLayer's creation (T0) and if performed at this early time the call deadlocks due to pthread_mutex wait for the shared user context. This fix performs NSOpenGLLayer creation and layer attachment while the shared user context is kept unlocked and enforces NSOpenGLLayer display and hence NSOpenGLLayer::openGLContextForPixelFormat(..). Added CGL.setNSOpenGLLayerEnabled(..) to enable/disable NSOpenGLLayer - currently not used. - Passed AddRemove tests for GLCanvas/Swing and GLWindow/NewtCanvasAWT w/ 100 loops on Java6 and Java7 on OSX. - Passed Instruments Leaks test w/ 10 loops on Java6 and Java7 --- .../opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java | 2 +- .../test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index 2038124b5..61652371b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -140,8 +140,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { if( visible ) { - jFrame.validate(); jFrame.pack(); + jFrame.validate(); } jFrame.setVisible(visible); } } ) ; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java index 0f12f967a..b4272a9c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java @@ -142,8 +142,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { if( visible ) { - jFrame.validate(); jFrame.pack(); + jFrame.validate(); } jFrame.setVisible(visible); } } ) ; -- cgit v1.2.3