aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
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
Diffstat (limited to 'src')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java23
1 files changed, 21 insertions, 2 deletions
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");