Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 743ec9da4ef93aead20dc65f36307fa4c1b8ed07
https://github.com/WebKit/WebKit/commit/743ec9da4ef93aead20dc65f36307fa4c1b8ed07
Author: Chris Dumez <[email protected]>
Date: 2026-10-01 (Thu, 01 Oct 2026)
Changed paths:
M Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp
M Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/WebThreadLock.mm
Log Message:
-----------
REGRESSION(317037@main): [iOS] WebKitLegacy apps crash when WebThreadRun() is
called off the main thread
https://bugs.webkit.org/show_bug.cgi?id=325919
rdar://185463537
Reviewed by Ryosuke Niwa.
When the WebThread is disabled, WebThreadRun() runs its block right away
on the calling thread. Callers that are not on the main thread end up
running WebCore code on a background thread. For example, the LSAppLink
completion handler in -[WebFramePolicyListener use] runs on an XPC reply
queue, and the crash happens in DocumentLoader::startLoadingMainResource().
WebKitLegacy API methods implemented with WebThreadRun() (-reload:,
-stopLoading:, -goBack, WebPreferences change notifications, ...) have the
same problem when an app calls them from a background thread.
When the WebThread is disabled and the caller is not on the main thread,
WebThreadRun() now queues the block on the main run loop.
CFRunLoopPerformBlock() is used rather than callOnMainThread() because
WTF main thread initialization may not have happened yet: WebThreadRun()
is SPI that may be called before any WebView exists, and
initializeMainThreadIfNeeded() defers initialization to the main run loop
when called off the main thread.
Test: WebKitLegacy.WebThreadRunWithoutWebThread
* Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp:
* Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/WebThreadLock.mm:
(TestWebKitAPI::TEST(WebKitLegacy, WebThreadRunWithoutWebThread)):
Canonical link: https://commits.webkit.org/322442@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications