summaryrefslogtreecommitdiffstats
path: root/make/config
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-03-14 10:48:44 +0100
committerSven Gothel <[email protected]>2013-03-14 10:48:44 +0100
commit896e8b021b39e9415040a57a1d540d7d24b02db1 (patch)
treec031248b4a464602aaa150b4d088235b9db065f0 /make/config
parent58f6f4e5665ae2c72ec6bbd86ad5a36bef00de07 (diff)
OSX/CALayer: Revise CALayer 'RunOnMainThread' utilization, avoiding deadlocks
RunOnMainThread(waitUntilDone:=true,..) can deadlock the main-thread if called from AWT-EDT, since the main-thread may call back to AWT-EDT while injecting a new main-thread task. This patch revises all RunOnMainThread CALayer usage, resulting in only one required left: - OSXUtil.AddCASublayer() w/ waitUntilDone:=false Hence the CALayer code has no more potential to deadlock main-thread/AWT-EDT. OSXUtil.AddCASublayer() must be performed on main-thread, otherwise the CALayer attachment will fail - no visible rendering result. +++ Note: A good trigger to test this deadlock is to magnify/zoom the OSX desktop (click background + ctrl-mouse_wheel) before running some unit tests. TestGLCanvasAWTActionDeadlock01AWT and TestAddRemove02GLWindowNewtCanvasAWT also have the potential to trigger the mentioned deadlock.
Diffstat (limited to 'make/config')
-rw-r--r--make/config/jogl/cgl-macosx-CustomJavaCode.java23
1 files changed, 7 insertions, 16 deletions
diff --git a/make/config/jogl/cgl-macosx-CustomJavaCode.java b/make/config/jogl/cgl-macosx-CustomJavaCode.java
index d32e0ae8f..ab1d44b64 100644
--- a/make/config/jogl/cgl-macosx-CustomJavaCode.java
+++ b/make/config/jogl/cgl-macosx-CustomJavaCode.java
@@ -1,9 +1,9 @@
/**
- * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program on Main-Thread
+ * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program
* <p>
- * It is mandatory that the shared context handle <code>ctx</code>
- * is not locked while calling this method.
+ * The NSOpenGLLayer will immediatly create a OpenGL context sharing the given ctx,
+ * which will be used to render the texture offthread.
* </p>
* <p>
* The NSOpenGLLayer starts in enabled mode,
@@ -12,10 +12,7 @@
*/
public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgramName, final long fmt, final long p,
final int texID, final boolean opaque, final int texWidth, final int texHeight) {
- return OSXUtil.RunOnMainThread(true, new Function<Long, Object>() {
- public Long eval(Object... args) {
- return Long.valueOf( createNSOpenGLLayerImpl(ctx, gl3ShaderProgramName, fmt, p, texID, opaque, texWidth, texHeight) );
- } } ).longValue();
+ return createNSOpenGLLayerImpl(ctx, gl3ShaderProgramName, fmt, p, texID, opaque, texWidth, texHeight);
}
/**
@@ -26,19 +23,13 @@ public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgra
* </p>
*/
public static void setNSOpenGLLayerEnabled(final long nsOpenGLLayer, final boolean enable) {
- OSXUtil.RunOnMainThread(true, new Runnable() {
- public void run() {
- setNSOpenGLLayerEnabledImpl(nsOpenGLLayer, enable);
- } } );
+ setNSOpenGLLayerEnabledImpl(nsOpenGLLayer, enable);
}
/**
- * Releases the NSOpenGLLayer on Main-Thread
+ * Releases the NSOpenGLLayer
*/
public static void releaseNSOpenGLLayer(final long nsOpenGLLayer) {
- OSXUtil.RunOnMainThread(true, new Runnable() {
- public void run() {
- releaseNSOpenGLLayerImpl(nsOpenGLLayer);
- } } );
+ releaseNSOpenGLLayerImpl(nsOpenGLLayer);
}