WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
302600
Fix main thread initialization when disabling WebThread
https://bugs.webkit.org/show_bug.cgi?id=302600
Summary
Fix main thread initialization when disabling WebThread
David Kilzer (:ddkilzer)
Reported
2025-11-16 15:14:52 PST
Fix main thread initialization when disabling WebThread. When WebThread is enabled, WebCore::initializeMainThreadIfNeeded() (via +[WebView initialize]) returns early because WebCore::StartWebThread() performs "main" thread initialization when the WebThread starts. When WebThread is disabled, WebCore::initializeMainThreadIfNeeded() no longer returns early, which means main thread initialization may now incorrectly occur on a background thread if +[WebView initialize] is called from there. We must avoid this issue in WebCore::initializeMainThreadIfNeeded() by only initializing the main thread if pthread_main_np() is true, else schedule main thread initialization asynchronously on the main thread (a best-effort) using CFRunLoopPerformBlock(). We can't use synchronous main thread initialization (for example, using a semaphore) in case an app is using their own locking mechanism to initialize WebView on a background thread from the main thread.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-11-16 15:15:14 PST
<
rdar://problem/164844902
>
David Kilzer (:ddkilzer)
Comment 2
2025-11-16 15:34:13 PST
Pull request:
https://github.com/WebKit/WebKit/pull/54015
EWS
Comment 3
2025-11-16 19:54:50 PST
Committed
303102@main
(f89bce6a688c): <
https://commits.webkit.org/303102@main
> Reviewed commits have been landed. Closing PR #54015 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug