commit 758d11aa5ef44dd50a55599b6eed4a2aa8e11326 Author: Jani Turkia Date: Mon Oct 21 18:36:24 2019 -0500 Moved manipulations of NSOpenGLContext and the NSView related to it to the main thread. In at least MacOS Catalina (10.15) the OpenGL context must be created and updated on the main thread only. This is from the crash report: -[NSOpenGLContext setView:] must be called from the main thread. diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index 462b539..dacaea3 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -14,6 +14,8 @@ #endif */ +#include + #import "MacOSXWindowSystemInterface.h" #import "ContextUpdater.h" @@ -556,7 +558,9 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, GLint zeroOpacity = 0; [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity]; } - [ctx setView:view]; // Bug 1087: Set default framebuffer, hence enforce NSView realization + dispatch_async(dispatch_get_main_queue(), ^{ // Fix for MacOS Catalina: -[NSOpenGLContext setView:] must be called from the main thread. + [ctx setView:view]; // Bug 1087: Set default framebuffer, hence enforce NSView realization + }); if( viewReadyAndLocked ) { [view unlockFocus]; } @@ -574,7 +578,9 @@ void setContextView(NSOpenGLContext* ctx, NSView* view) { Bool viewReadyAndLocked = lockViewIfReady(view); DBG_PRINT("setContextView.0: ctx %p, view %p: setView: %d\n", ctx, view, viewReadyAndLocked); if( viewReadyAndLocked ) { - [ctx setView:view]; + dispatch_async(dispatch_get_main_queue(), ^{ + [ctx setView:view]; + }); [view unlockFocus]; } } @@ -655,7 +661,9 @@ void updateContext(NSOpenGLContext* ctx) { NSView *nsView = [ctx view]; if(NULL != nsView) { DBG_PRINT("updateContext.0: ctx %p, ctx.view %p\n", ctx, nsView); - [ctx update]; + dispatch_async(dispatch_get_main_queue(), ^{ + [ctx update]; + }); DBG_PRINT("updateContext.X\n"); } [pool release];