Skip to content

Commit a6baad8

Browse files
committed
Dispatch preferencesChanged WebKit calls to the main thread
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 #563 (duplicate commits race)
1 parent 21e5ff0 commit a6baad8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Classes/Controllers/PBWebHistoryController.m‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ - (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *
346346

347347
- (void)preferencesChanged
348348
{
349-
[[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil];
349+
dispatch_async(dispatch_get_main_queue(), ^{
350+
[[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil];
351+
});
350352
}
351353

352354
@end

0 commit comments

Comments
 (0)