summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-09-08 12:56:57 +0200
committerSven Gothel <[email protected]>2019-09-08 12:56:57 +0200
commit534d764474cacf8bc380123cbfd164c7c55f236a (patch)
treef87a883e0962df6a8e6d9270967527fba943e37c
parent125e4bd1c8e0a8f4b434209b155e6cd0d8f09092 (diff)
Buig 1389: Fix SIGSEGV on OpenJDK11 on [NSApplicationAWT sendEvent:]
Culprit of the crash and the non propagated action on NSApp main-thread was _simply_ our OSXUtil_KickNSApp() 'kick alive' NSApplicationDefined NSEvent sent to the NSApp. Java11's NSApp code overrides sendEvent and handles NSApplicationDefined + subtype=ExecuteBlockEvent using the given data1 as a function pointer. 8-O ExecuteBlockEvent defined as 0, which we have sent. Simply passing subtype=8888 avoids this side-effect. Whether it is still required to KickNSApp() is another question. +++ Further, make code a bit more robuts regarding the offscreenSurfaceLayer at JAWTWindow invalidate. I.e. if still not detached, do the late cleanup there. This just in case the OSX Context callback to disassociate the drawable has been missed.
-rw-r--r--make/scripts/tests-osx-junit-swt.sh (renamed from make/scripts/tests-macosx64-junit-swt.sh)0
-rwxr-xr-xmake/scripts/tests-osx-x64-java8.sh18
-rwxr-xr-xmake/scripts/tests-osx-x64.sh2
-rw-r--r--make/scripts/tests.sh8
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java2
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java3
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java7
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java7
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java6
10 files changed, 44 insertions, 18 deletions
diff --git a/make/scripts/tests-macosx64-junit-swt.sh b/make/scripts/tests-osx-junit-swt.sh
index 2a6ccd63a..2a6ccd63a 100644
--- a/make/scripts/tests-macosx64-junit-swt.sh
+++ b/make/scripts/tests-osx-junit-swt.sh
diff --git a/make/scripts/tests-osx-x64-java8.sh b/make/scripts/tests-osx-x64-java8.sh
new file mode 100755
index 000000000..7643919bc
--- /dev/null
+++ b/make/scripts/tests-osx-x64-java8.sh
@@ -0,0 +1,18 @@
+#! /bin/bash
+
+#export DYLD_LIBRARY_PATH=$HOME/ffmpeg-0.8_0.9/lib:$DYLD_LIBRARY_PATH
+#export DYLD_LIBRARY_PATH=$HOME/ffmpeg-2.2.3/lib:$DYLD_LIBRARY_PATH
+export DYLD_LIBRARY_PATH=/usr/local/Cellar/ffmpeg/2.8/lib:$DYLD_LIBRARY_PATH
+
+#JAVA_HOME=`/usr/libexec/java_home`
+JAVA_HOME=`/usr/libexec/java_home -version 1.8`
+#JAVA_HOME=`/usr/libexec/java_home -version 11`
+PATH=$JAVA_HOME/bin:$PATH
+export JAVA_HOME PATH
+
+export SWT_CLASSPATH=`pwd`/lib/swt/cocoa-macosx-x86_64/swt.jar
+
+spath=`dirname $0`
+
+. $spath/tests.sh $JAVA_HOME/bin/java -DummyArg ../build-macosx $*
+
diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh
index d0f244e93..67f3aaa50 100755
--- a/make/scripts/tests-osx-x64.sh
+++ b/make/scripts/tests-osx-x64.sh
@@ -14,5 +14,5 @@ export SWT_CLASSPATH=`pwd`/lib/swt/cocoa-macosx-x86_64/swt.jar
spath=`dirname $0`
-. $spath/tests.sh $JAVA_HOME/bin/java -DummyArg ../build-macosx $*
+. $spath/tests.sh $JAVA_HOME/bin/java --illegal-access=warn ../build-macosx $*
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 95917b7b5..75faeae3a 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -107,7 +107,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
#D_ARGS="-Djogl.debug.GLProfile -Djogl.debug.GLContext -Djogl.quirks.force=GL3CompatNonCompliant,NoSurfacelessCtx -Djogl.disable.opengles"
#D_ARGS="-Djogl.quirks.force=NoDoubleBufferedPBuffer"
- D_ARGS="-Dnativewindow.debug.GraphicsConfiguration"
+ #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000"
#D_ARGS="-Djogamp.debug=all"
@@ -120,7 +120,9 @@ function jrun() {
#D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.UnsafeUtil"
+ #D_ARGS="-Dnativewindow.debug.OSXUtil -Dnativewindow.debug.JAWT -Djogl.debug.GLContext -Djogl.debug.GLCanvas"
#X_ARGS="--illegal-access=warn"
+
#D_ARGS="-Djogamp.debug.NativeLibrary=true -Djogamp.debug.JNILibLoader=true"
#D_ARGS="-Djogl.debug.GLContext -Djogamp.debug.NativeLibrary -Djogamp.debug.JNILibLoader -Djogl.debug.DebugGL -Djogl.debug.GLDebugMessageHandler"
#D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogl.debug.GLContext"
@@ -947,7 +949,7 @@ function testawtswt() {
# 2.4.0 Regressions
#
# OSX
-#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
# Linux Mesa/AMD:
@@ -959,7 +961,7 @@ function testawtswt() {
# Linux Mesa/Soft
#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
# ATI/Linux: XCB Unknown request in queue while dequeuing
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 995ff870e..718216315 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -924,7 +924,7 @@ public class MacOSXCGLContext extends GLContextImpl
// All CALayer lifecycle ops are deferred on main-thread
final DetachGLLayerCmd dCmd = new DetachGLLayerCmd(cmd);
if(DEBUG) {
- System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable(false): "+dCmd);
+ System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable(false): "+dCmd+" - "+Thread.currentThread().getName());
}
OSXUtil.RunOnMainThread(false, true /* kickNSApp */, dCmd);
if( null != gl3ShaderProgram ) {
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 71a7602e6..5b8171e96 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -270,6 +270,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
invalidateNative();
jawt = null;
awtConfig = null;
+ offscreenSurfaceLayer = 0; // Bug 1389
isOffscreenLayerSurface = false;
drawable= 0;
drawable_old = 0;
@@ -534,7 +535,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
throw new NativeWindowException("No offscreen layer attached: "+this);
}
if(DEBUG) {
- System.err.println("JAWTWindow.detachSurfaceHandle(): osh "+toHexString(offscreenSurfaceLayer));
+ System.err.println("JAWTWindow.detachSurfaceHandle(): osh "+toHexString(offscreenSurfaceLayer)+" - "+Thread.currentThread().getName());
}
detachSurfaceLayerImpl(offscreenSurfaceLayer, detachSurfaceLayerNotify);
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 5a0c8a79a..f67cc7189 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -89,6 +89,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
", osd-set "+offscreenSurfaceDrawableSet+
", osd "+toHexString(offscreenSurfaceDrawable)+
", osl "+toHexString(getAttachedSurfaceLayer())+
+ ", jsl "+toHexString(jawtSurfaceLayersHandle)+
", rsl "+toHexString(rootSurfaceLayer)+
", wh "+toHexString(windowHandle)+" - "+Thread.currentThread().getName());
}
@@ -98,9 +99,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
if(0 != windowHandle) {
OSXUtil.DestroyNSWindow(windowHandle);
}
+ final long _offscreenSurfaceLayer = getAttachedSurfaceLayer(); // Bug 1389
OSXUtil.RunOnMainThread(false, true /* kickNSApp */, new Runnable() {
@Override
public void run() {
+ if( 0 != _offscreenSurfaceLayer ) { // Bug 1389
+ OSXUtil.RemoveCASublayer(rootSurfaceLayer, _offscreenSurfaceLayer, true);
+ }
if( 0 != jawtSurfaceLayersHandle) {
// null rootSurfaceLayer OK
UnsetJAWTRootSurfaceLayer0(jawtSurfaceLayersHandle, rootSurfaceLayer);
@@ -211,7 +216,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
@Override
public void run() {
detachNotify.run();
- OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle);
+ OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle, false);
} });
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index e93c9574f..623880dd5 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -232,15 +232,16 @@ public class OSXUtil implements ToolkitProperties {
/**
* Detach a sub CALayer from the root CALayer.
+ * @param subCALayerRelease if true, native call will issue a final {@code [subCALayerRelease release]}.
*/
- public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) {
+ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer, final boolean subCALayerRelease) {
if(0==rootCALayer || 0==subCALayer) {
throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer));
}
if(DEBUG) {
System.err.println("OSXUtil.DetachCALayer: 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName());
}
- RemoveCASublayer0(rootCALayer, subCALayer);
+ RemoveCASublayer0(rootCALayer, subCALayer, subCALayerRelease);
}
/**
@@ -414,7 +415,7 @@ public class OSXUtil implements ToolkitProperties {
private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, float contentsScale, int caLayerQuirks);
private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, boolean visible, int x, int y, int width, int height, int caLayerQuirks);
private static native void SetCALayerPixelScale0(long rootCALayer, long subCALayer, float contentsScale);
- private static native void RemoveCASublayer0(long rootCALayer, long subCALayer);
+ private static native void RemoveCASublayer0(long rootCALayer, long subCALayer, boolean subCALayerRelease);
private static native void DestroyCALayer0(long caLayer);
private static native void RunOnMainThread0(boolean kickNSApp, Runnable runnable);
private static native void RunLater0(boolean onMain, boolean kickNSApp, Runnable runnable, int delay);
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 1135c5fb2..a24f9291e 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -807,10 +807,10 @@ NS_ENDHANDLER
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
* Method: RemoveCASublayer0
- * Signature: (JJ)V
+ * Signature: (JJZ)V
*/
JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0
- (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer)
+ (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jboolean subCALayerRelease)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer);
@@ -826,6 +826,9 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0
[subLayer removeFromSuperlayer];
[subLayer release]; // Pairs w/ AddCASublayer
+ if( subCALayerRelease ) {
+ [subLayer release];
+ }
[rootLayer release]; // Pairs w/ AddCASublayer
[CATransaction commit];
@@ -1051,7 +1054,7 @@ static void OSXUtil_KickNSApp() {
timestamp: 0.0
windowNumber: 0
context: nil
- subtype: 0
+ subtype: 8888 /* Bug 1389: Avoid JDK impl sendEvent types, utilizing data1 or data2 */
data1: 0
data2: 0];
[NSApp postEvent: event atStart: true];
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
index c23512005..71864d914 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java
@@ -160,11 +160,7 @@ public class TestGearsAWT extends UITestCase {
}
}
if(waitForKey) {
- final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- System.err.println("Press enter to continue");
- try {
- System.err.println(stdin.readLine());
- } catch (final IOException e) { }
+ waitForKey("Start Test");
}
org.junit.runner.JUnitCore.main(TestGearsAWT.class.getName());
}