diff options
author | Sven Gothel <[email protected]> | 2015-09-01 05:19:14 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-09-01 05:19:14 +0200 |
commit | 85b32bac4f031dbdb55caa380d5a20440aecbbbd (patch) | |
tree | 7c458b43e770b6046c7f918b8383077432389488 | |
parent | aacc8afdca0b1376f91dcc68aa3ae3b39c7aba51 (diff) |
Bug 1212 - OSX: Crash using CALayer at UnsetJAWTRootSurfaceLayer0(..) w/ Java 1.8.0_60
- OSX 10.10.5
- Java 1.8.0_60
Crash using CALayer at UnsetJAWTRootSurfaceLayer0(..)
as called within MacOSXJAWTWindow.invalidateNative() (caller: destroy())
on the MainThread.
It has been observed that the
JAWT_SurfaceLayers protocol instance 'surfaceLayers' has been pulled beforehand.
'surfaceLayers' is fetched from the locked JAWT instance
via JAWT_DrawingSurfaceInfo's platformInfo.
It now seems required to retain the instance
at GetJAWTSurfaceLayersHandle0 and release it
at UnsetJAWTRootSurfaceLayer0 to keep it alive.
+++
Manually executed 'ant junit.run' on OSX, no failures or errors.
-rw-r--r-- | make/scripts/tests.sh | 4 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 9 | ||||
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 34 |
3 files changed, 30 insertions, 17 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4ce43dc6c..b5579c01c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -427,8 +427,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2SimpleNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $* diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 264bdf9d3..5a0c8a79a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -101,14 +101,15 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RunOnMainThread(false, true /* kickNSApp */, new Runnable() { @Override public void run() { + if( 0 != jawtSurfaceLayersHandle) { + // null rootSurfaceLayer OK + UnsetJAWTRootSurfaceLayer0(jawtSurfaceLayersHandle, rootSurfaceLayer); + } + jawtSurfaceLayersHandle = 0; if( 0 != rootSurfaceLayer ) { - if( 0 != jawtSurfaceLayersHandle) { - UnsetJAWTRootSurfaceLayer0(jawtSurfaceLayersHandle, rootSurfaceLayer); - } OSXUtil.DestroyCALayer(rootSurfaceLayer); rootSurfaceLayer = 0; } - jawtSurfaceLayersHandle = 0; } }); } diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 919108db9..ce4a3b7ee 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -861,8 +861,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Ge NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); return 0; } - id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo; - return (jlong) ((intptr_t) surfaceLayers); + NSObject *surfaceLayersObj = (NSObject*) dsi->platformInfo; + [surfaceLayersObj retain]; // Pairs w/ Unset + DBG_PRINT("CALayer::GetJAWTSurfaceLayersHandle: surfaceLayers %p (refcnt %d)\n", surfaceLayersObj, (int)[surfaceLayersObj retainCount]); + + id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj; + return (jlong) (intptr_t) surfaceLayers; } /* @@ -878,9 +882,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Set [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)(intptr_t)jawtSurfaceLayersHandle; + NSObject *surfaceLayersObj = (NSObject*) (intptr_t) jawtSurfaceLayersHandle; + id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj; MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: pre %p -> root %p (refcnt %d)\n", [surfaceLayers layer], layer, (int)[layer retainCount]); + [surfaceLayers setLayer: [layer retain]]; // Pairs w/ Unset [CATransaction commit]; @@ -902,20 +908,26 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Uns [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)(intptr_t)jawtSurfaceLayersHandle; + NSObject *surfaceLayersObj = (NSObject*) (intptr_t) jawtSurfaceLayersHandle; + id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj; + DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: surfaceLayers %p (refcnt %d)\n", surfaceLayersObj, (int)[surfaceLayersObj retainCount]); + MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; - if(layer != [surfaceLayers layer]) { - NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); - return; + if(NULL != layer) { + if(layer != [surfaceLayers layer]) { + NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); + return; + } + DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.1: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); + [layer release]; // Pairs w/ Set + [surfaceLayers setLayer: NULL]; // Pairs w/ Set } - DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); - [layer release]; // Pairs w/ Set - [surfaceLayers setLayer: NULL]; + [surfaceLayersObj release]; // Pairs w/ Get [CATransaction commit]; [pool release]; - DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); + DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X\n"); } @interface MainRunnable : NSObject |