aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-09-09 09:36:50 +0200
committerSven Gothel <[email protected]>2019-09-09 09:36:50 +0200
commit7e76df3a05b7eb2404cb4584ee0b34ea287eb9bf (patch)
treedf8c14a77cf875222e3347ebe1934e06e00a9f39
parente33aa16904d8abddaeceb1374ffa45bd45a96210 (diff)
Bug 1393: OSXUtil: Optionally inject Apple's 'Main Thread Checker'java11ios
To allow proper testing of whether all AppKit calls are performed on its Main-Thread where required, we inject the libMainThreadChecker.dylib when property 'nativewindow.debug.OSXUtil.MainThreadChecker' is set. See <https://developer.apple.com/documentation/code_diagnostics/main_thread_checker?language=objc> Lib-Name: /Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib
-rw-r--r--make/build-newt.xml2
-rw-r--r--make/scripts/tests.sh13
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java23
3 files changed, 34 insertions, 4 deletions
diff --git a/make/build-newt.xml b/make/build-newt.xml
index b01249415..f33142e0a 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -586,6 +586,8 @@
<linkerarg value="-weak_framework" />
<linkerarg value="AppKit" />
<linkerarg value="-weak_framework" />
+ <linkerarg value="QuartzCore" />
+ <linkerarg value="-weak_framework" />
<linkerarg value="Carbon" />
<linkerarg value="-weak_framework" />
<linkerarg value="Cocoa" />
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 75faeae3a..6255812b4 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -120,7 +120,10 @@ 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"
+ #D_ARGS="-Dnativewindow.debug.OSXUtil -Dnativewindow.debug.JAWT -Djogl.debug.GLContext"
+ #D_ARGS="-Dnewt.debug.Window"
+ #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000 -Dnewt.debug.EDT"
+ D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Dnativewindow.debug.OSXUtil.MainThreadChecker"
#X_ARGS="--illegal-access=warn"
#D_ARGS="-Djogamp.debug.NativeLibrary=true -Djogamp.debug.JNILibLoader=true"
@@ -949,8 +952,14 @@ 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.awt.TestAWT02WindowClosing
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $*
# Linux Mesa/AMD:
#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $*
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 196cdff57..f84955e69 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -31,6 +31,11 @@ import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.NativeWindowFactory;
import com.jogamp.nativewindow.util.Insets;
import com.jogamp.nativewindow.util.Point;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import com.jogamp.common.os.NativeLibrary;
import com.jogamp.common.util.Function;
import com.jogamp.common.util.FunctionTask;
import com.jogamp.common.util.InterruptedRuntimeException;
@@ -55,12 +60,26 @@ public class OSXUtil implements ToolkitProperties {
*/
public static synchronized void initSingleton() {
if(!isInit) {
- if(DEBUG) {
- System.out.println("OSXUtil.initSingleton()");
+ final boolean useMainThreadChecker = Debug.debug("OSXUtil.MainThreadChecker");
+ if(DEBUG || useMainThreadChecker) {
+ System.out.println("OSXUtil.initSingleton() - useMainThreadChecker "+useMainThreadChecker);
}
if(!NWJNILibLoader.loadNativeWindow("macosx")) {
throw new NativeWindowException("NativeWindow MacOSX native library load error.");
}
+ if( useMainThreadChecker ) {
+ final String libMainThreadChecker = "/Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib";
+ final NativeLibrary lib = AccessController.doPrivileged(new PrivilegedAction<NativeLibrary>() {
+ @Override
+ public NativeLibrary run() {
+ return NativeLibrary.open(libMainThreadChecker, false, false, OSXUtil.class.getClassLoader(), true);
+ } } );
+ if( null == lib ) {
+ System.err.println("Could not load "+libMainThreadChecker);
+ } else {
+ System.err.println("Loaded "+lib);
+ }
+ }
if( !initIDs0() ) {
throw new NativeWindowException("MacOSX: Could not initialized native stub");