Currently it's created on the main thread and CreateAndStart() is delayed when the main thread is busy.
Making the subresource loader factory on the IO thread will resolve the performance issue.
Summary: Avoid hopping back to main thread for ServiceWorkerSubresourceLoaderFactory (was: Create ServiceWorkerSubresourceLoaderFactory for pages on IO thread)
Changing the summary.
The point is we shouldn't run SWSubresourceLoaderFactory tasks asyncly on the main thread, which can be largely delayed if there's a long-running task. We should be able to fix this either by:
1) Create SWSubresourceLoaderFactory on a different thread (e.g. on IO thread or on a background thread. In our case this needs to be the background thread as SWSubresourceLoader needs to be able to issue sync IPCs to resolve blobs without deadlock (when Network Service is not enabled).
This is being explored by: https://chromium-review.googlesource.com/c/chromium/src/+/1109662
2) Avoid using mojo for going through ServiceWorkerSubresourceLoaderFactory, at least for document cases. (For worker cases we still need the thread-hop to avoid dead-lock with sync XHR)
I'll also look into #2
For the record for ourselves:
https://chromium-review.googlesource.com/c/chromium/src/+/1111759 is a PoC patch for #2, but measurement result was worse than approach #1 (while still better than original).
Hypothesis here is for network fallback cases we still need to come back to the main thread with #2, while not with #1.
Comment 1 by kinuko@chromium.org
, Jun 22 2018