Open the file dialogs on the main thread (fixes crash on macOS) - #13
Merged
Merged
Conversation
The native file dialogs were opened with `fetch(Threads.@Spawn pick_file(""))`. As soon as Julia runs with more than one thread (the default in VS Code), the spawned task ends up on another thread and macOS aborts Julia: NSInternalInconsistencyException: 'NSWindow should only be instantiated on the main thread!' (e.g. when clicking "Load Profile..."). The dialogs are now called directly from the `@async` blocks, which stay on the main thread. The dialogs are modal anyway, so nothing is lost by not spawning them. Co-Authored-By: Claude Opus 5.5 (1M context) <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.
Problem
On macOS, clicking Load Profile… (or any other menu entry that opens a file dialog) kills Julia:
The dialogs are opened with
fetch(Threads.@spawn PICK_FILE[]("")). As soon as Julia runs with more than one thread – the default in VS Code – the spawned task runs on another thread, and macOS only allows windows to be created on the main thread. Minimal reproduction:Fix
Call
PICK_FILE[]("")/SAVE_FILE[]("")directly inside the existing@asyncblocks, which stay on the main thread (6 places inAdA_VizPickTool_V1.jlandFileIO/fileIO_utils.jl). The dialogs are modal anyway, so spawning them gained nothing.Tests
julia -t 4works (dialog opens, no abort); from a spawned task it aborts as above.Pkg.test()withjulia -t 4: 34/34 passed.🤖 Generated with Claude Code