Skip to content

Dispatch preferencesChanged WebKit calls to the main thread - #565

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-latent-bug
Aug 11, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-latent-bug

Conversation

@goneng

@goneng goneng commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

PBWebHistoryController's preferencesChanged touched WebView's windowScriptObject synchronously from whatever thread posted NSUserDefaultsDidChangeNotification. WebKit requires windowScriptObject to be accessed only on the main thread and raises WebKitThreadingException otherwise, crashing the process.

Changes

Test plan

  • Verify GitX still updates its web views normally after a preference change (main-thread path unaffected)
  • Confirm a background-thread NSUserDefaultsDidChangeNotification no longer crashes with WebKitThreadingException

PBWebHistoryController's preferencesChanged touched WebView's
windowScriptObject synchronously from whatever thread posted
NSUserDefaultsDidChangeNotification. WebKit requires
windowScriptObject to be accessed only on the main thread and
raises WebKitThreadingException otherwise, crashing the process.

- Wrap the script call in dispatch_async(dispatch_get_main_queue())
- Found via the new GitXTests unit-test target: XCTest's bootstrap
  registers NSUserDefaults from a background thread during process
  startup, crashing GitX consistently
- Unrelated to issue gitx#563 (duplicate commits race)
@hannesa2
hannesa2 merged commit d34b1d2 into gitx:master Aug 11, 2026
3 checks passed
@goneng
goneng deleted the fix-latent-bug branch August 11, 2026 19:19
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