From 1711008b95534d1bf3c87570990253c0fa7cd9f6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 22 Jan 2023 03:14:21 +0100 Subject: MacOS: JAWTWindow: Complete MacOS 12+ SIGSEGV JAW Crash Fix; This: Destroy NSWindow on MacOS main-thread Destroy NSWindow on MacOS main-thread, avoiding spurious more rare SIGSEGV on MacOS 13/aarch64 This closes the MacOS 12+ SIGSEGV JAWT (CALayer) crash fix, see commits: - 4009198e34b50bba9582be24f33eaf83b94a2cb8 - 3c4cf1f37dc27d8d527804d195361a2287575147 - d969f473fdc72c6ca95f1796ff5af3f0c8bd51b6 - 81f395975c06a66183ad36cc43e8dc9bc7f4545b - b8977465b2fb8452c2560a5d2561b2561472edf0 - 470a0ff3a2efbe43404d5f80a403efb38005598a - 9829550f5bcb586f94f98f6d3c39f4d78fd78f3b --- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/nativewindow') diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index aeb623669..e754bb262 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -95,9 +95,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { offscreenSurfaceDrawable=0; offscreenSurfaceDrawableSet=false; if( isOffscreenLayerSurfaceEnabled() ) { - if(0 != windowHandle) { - OSXUtil.DestroyNSWindow(windowHandle); - } + final long _windowHandle = windowHandle; + windowHandle = 0; final long _rootSurfaceLayer = rootSurfaceLayer; rootSurfaceLayer = 0; final long _jawtSurfaceLayersHandle = jawtSurfaceLayersHandle; @@ -105,6 +104,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RunOnMainThread(false /* wait */, true /* kickNSApp */, new Runnable() { @Override public void run() { + if(0 != _windowHandle) { + OSXUtil.DestroyNSWindow(_windowHandle); + } if( 0 != _rootSurfaceLayer && 0 != _offscreenSurfaceLayer ) { // Bug 1389 // throws if null == _rootSurfaceLayer OSXUtil.RemoveCASublayer(_rootSurfaceLayer, _offscreenSurfaceLayer, true); @@ -372,8 +374,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } if(null != errMsg) { if(0 != windowHandle) { - OSXUtil.DestroyNSWindow(windowHandle); - windowHandle = 0; + final long _windowHandle = windowHandle; + windowHandle = 0; + OSXUtil.RunOnMainThread(false /* wait */, false, new Runnable() { + @Override + public void run() { + OSXUtil.DestroyNSWindow(_windowHandle); + } } ); } drawable = 0; unlockSurfaceImpl(); -- cgit v1.2.3