In the current implementation, top-level shared worker script is fetched from the main thread via WorkerClassicScriptLoader (see WebSharedWorkerImpl::OnShadowPageInitialized()). To avoid dependencies on the main thread, that should be done from the worker thread.
Implementation plan
1) Add a runtime flag like OffMainThreadSharedWorkerScriptFetch, and wrap following steps with flag checks.
2) In WebSharedWorkerImpl::OnShadowPageInitialize(), bypass WorkerClassicScriptLoader creation, and call client_->WaitForServiceWorkerControllerInfo() and WebSharedWorkerImpl::ContinueOnScriptLoaderFinished().
3) In WebSharedWorkerImpl::StartWorkerThread(), call WorkerThread::ImportClassicScript() instead of WorkerThread::EvaluateClassicScript(). The function eventually fetches a worker script and evaluates it on the worker thread.
4) We also need to plumb PlzSharedWorker in the case where NetworkService is enabled.
Testing plan
- Run web_tests with the OffMainThreadSharedWorkerScriptFetch flag. For references, see "omt-worker-fetch" in VirtualTestSuites ("omt-worker-fetch" is the test setting for off-the-main-thread dedicated worker script fetch).
- Run web_tests with the OffMainThreadSharedWorkerScriptFetch and NetworkService flags for PlzSharedWorker.
References
- dedicated_worker.cc does the similar thing for off-the-main-thread dedicated worker script fetch. Search the code by RuntimeEnabledFeatures::OffMainThreadWorkerScriptFetchEnabled.
Comment 1 by nhiroki@chromium.org
, Today (16 hours ago)Status: Started (was: Available)