From d8e808a5ec1d7ff936486c33219216cb39decb39 Mon Sep 17 00:00:00 2001 From: MilanKlausz Date: Tue, 3 Nov 2026 10:10:46 +0100 Subject: [PATCH] G4OSG viewer: render in the main thread on macOS After a window resize (or the window being brought to the front), osgViewer's GraphicsWindowCocoa calls [NSOpenGLContext update] in the next makeCurrent. AppKit only allows that on the main thread, so the draw thread of the default threading model, (re)started by startThreading() (e.g. when the axes or the hover text change), dies with SIGILL (Illegal instruction: 4). Co-Authored-By: Claude Opus 5.5 --- src/simplebuild_dgcode/data/pkgs/G4/G4OSG/libsrc/Viewer.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/simplebuild_dgcode/data/pkgs/G4/G4OSG/libsrc/Viewer.cc b/src/simplebuild_dgcode/data/pkgs/G4/G4OSG/libsrc/Viewer.cc index 0ae7e293..9c4a0969 100644 --- a/src/simplebuild_dgcode/data/pkgs/G4/G4OSG/libsrc/Viewer.cc +++ b/src/simplebuild_dgcode/data/pkgs/G4/G4OSG/libsrc/Viewer.cc @@ -208,6 +208,13 @@ void G4OSG::Viewer::init() compviewer->setKeyEventSetsDone(0);//no quit +#ifdef __APPLE__ + //macOS: after a window resize (fullscreen toggle, user resize), osgViewer + //calls [NSOpenGLContext update] in the next makeCurrent, which AppKit only + //allows on the main thread. A draw thread (re)started by startThreading() + //then dies with SIGILL, so render in the main thread: + compviewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded); +#endif m_viewer->setUpThreading(); // clear stencil buffer... (for outline FX)