I landed the patch of "Reuse unmatched service worker processes for navigation".
https://chromium-review.googlesource.com/c/535220/
So now, the PlzNavigate's navigation will reuse the 'unmathced' service worker process.
But while I'm inspecting the logic of PlzNavigate, I found a edge case where two processes are created for service worker and navigation.
When PlzNavigate is enabled, a SiteInstance and a RenderProcessHost is created when NavigatorImpl::NavigateToPendingEntry() is called.
[1] NavigatorImpl::NavigateToPendingEntry()
=> NavigatorImpl::NavigateToEntry()
=> NavigatorImpl::RequestNavigation()
=> FrameTreeNode::CreatedNavigationRequest()
=> RenderFrameHostManager::DidCreateNavigationRequest()
=> RenderFrameHostManager::GetFrameHostForNavigation()
=> RenderFrameHostManager::CreateSpeculativeRenderFrameHost()
=> SiteInstanceImpl::GetProcess()
But RenderProcessHostImpl::AddExpectedNavigationToSite() is called when NavigatorImpl::OnBeginNavigation() is called asynchronously after NavigateToPendingEntry() is called.
[2] NavigatorImpl::OnBeginNavigation()
=> NavigationRequest::BeginNavigation()
=> NavigationHandleImpl::WillStartRequest()
=> NavigationRequest::OnStartChecksComplete()
=> RenderProcessHostImpl::AddExpectedNavigationToSite()
If the service worker is speculatively started from Omnibox, ServiceWorkerProcessManager::AllocateWorkerProcess() may be called between [1] NavigatorImpl::NavigateToPendingEntry() and [2] NavigatorImpl::OnBeginNavigation().
In that case, AllocateWorkerProcess() creates a new process.
I think it is a rare case. But I want to file a bug not to forget about it.
Comment 1 by creis@chromium.org
, Jun 29 2017Components: UI>Browser>Navigation
Owner: clamy@chromium.org