Repository navigation
G4OSG viewer: render in the main thread on macOS (fixes SIGILL crash) - #60
Merged
Merged
Conversation
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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS the G4OSG viewer (
--viewer) crashes withIllegal instruction: 4(SIGILL). It happens after thewindow has been resized (F/F5 fullscreen toggle, resizing by hand, or the window being brought to the front),
as soon as osgViewer restarts its draw thread, e.g. when the axes are toggled (CTRL-A) or the hover text
changes.
The crash report always has the same stack in the draw thread:
with the message
-[NSOpenGLContext update] must be called from the main thread if the context has a view.After a resize,
GraphicsWindowCocoacalls[NSOpenGLContext update]in the nextmakeCurrent, and AppKitonly allows that on the main thread.
The fix: on macOS (
#ifdef __APPLE__) the viewer uses osgViewer'sSingleThreadedthreading model, so allrendering is in the main thread. Other platforms are unchanged.
Tested on macOS 26 (Apple silicon), simple-build-dgcode 2.0.1 from conda-forge, OpenSceneGraph 3.6.5,
Geant4 11.4.3:
🤖 Generated with Claude Code