Skip to content

Fix thread safety: dispatch native AppKit/NSUserDefaults reads to main thread - #10

Open
karlvr wants to merge 1 commit into
violetlib:masterfrom
karlvr:fix/native-main-thread
Open

Fix thread safety: dispatch native AppKit/NSUserDefaults reads to main thread#10
karlvr wants to merge 1 commit into
violetlib:masterfrom
karlvr:fix/native-main-thread

Conversation

@karlvr

@karlvr karlvr commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

A couple more native threading suggestions:

  • nativeGetApplicationAppearanceName was reading NSApp.appearance directly from the JNI calling thread.
  • nativeGetAppearanceSettings was reading NSUserDefaults and NSWorkspace accessibility properties off the main thread. Both now use runOnMainThread to safely access these APIs. Also we're gathering this information all at once, on the main thread, to prevent any races if things change and result in maybe inconsistencies.

…n thread

nativeGetApplicationAppearanceName was reading NSApp.appearance directly from the JNI calling thread. nativeGetAppearanceSettings was reading NSUserDefaults and NSWorkspace accessibility properties off the main thread. Both now use runOnMainThread to safely access these APIs.
@cbfiddle

Copy link
Copy Markdown
Contributor

Oddly enough, I experienced a beach ball today that might have been caused by this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants