fix(macos): leave host-owned NSApplication alone (#5)#6
Merged
Conversation
When a host UI toolkit (JavaFX/Glass, Compose/Skiko, AWT) already owns NSApplication and is running its event loop, libtray was re-running [NSApp finishLaunching] and flipping the activation policy to Accessory. On JavaFX/Intel that destabilised Glass's CVDisplayLink pulse timer and crashed the JVM with a SIGSEGV in objc_msgSend right after startup. Gate the bootstrap on [NSApp isRunning]: only set the activation policy and finishLaunching when libtray itself owns NSApp (headless/smoke, where isRunning is false at create time). Host-owned apps get just the status item, since the host already did the launch bootstrap.
Adds an isolated javafxSmoke source set + runJavaFxSmoke task that brings up a real JavaFX toolkit and then creates a libtray tray from the FX Application Thread -- the exact state ([NSApp isRunning] == true) where the upstream consumer crashed. runSmoke could not reproduce it because it owns the NSApp bootstrap itself. JavaFX is verification-scoped only: separate source set, never in the published artifact or the main/test classpath. The task does not force -XstartOnFirstThread (JavaFX manages its own main thread); pass -PfxFirstThread to override if a host needs it.
…Macs JavaFX 25 defaults to Metal on macOS; a QEMU macOS VM has no Metal GPU and dies in MTLContext_nInitialize before reaching the tray. Pin prism.order=sw for runJavaFxSmoke. The #5 crash is in Glass's CVDisplayLink pulse timer, independent of the render backend, so the repro stays valid under software rendering.
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.
Summary
When a host UI toolkit (JavaFX/Glass, Compose/Skiko, AWT) already owns
NSApplication and is running its event loop, the macOS backend was
re-running
[NSApp finishLaunching]and flipping the activation policy toAccessory on tray creation. On JavaFX/Intel this destabilised Glass's
CVDisplayLink pulse timer and crashed the JVM with a SIGSEGV in
objc_msgSendright after startup.[NSApp isRunning]: a host-owned app getsjust the status item; libtray still bootstraps NSApp when it owns it
(headless / smoke).
runJavaFxSmoke, isolated source set) thatrecreates the crash from the FX Application Thread; pins
prism.order=swso JavaFX starts on headless / VM Macs.Reproduced and verified on an Intel macOS VM: unpatched build SIGSEGVs,
patched build brings the tray up with no crash.
Closes #5
Test plan
./gradlew testgreenrunJavaFxSmoke: unpatched crashes in objc_msgSend, patched does not (Intel macOS VM A/B)runSmokestill works (libtray owns NSApp, isRunning false at create)