Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Issue 2774513003: PlzNavigate: ensure we create a ServiceWorkerProviderHost (Closed)

Created:
3 years, 9 months ago by clamy
Modified:
3 years, 8 months ago
Reviewers:
falken, michaeln, jam, nasko
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, shimazu+serviceworker_chromium.org, serviceworker-reviews, jam, nhiroki, kinuko+serviceworker, horo+watch_chromium.org, darin-cc_chromium.org, kinuko+watch, tzik, blink-worker-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

PlzNavigate: ensure we create a ServiceWorkerProviderHost Prior to this CL, it was possible for ServiceWorkerDispatcherHost::OnProviderCreated to return without ensuring that a ServiceWorkerProviderHost had been added to the ServiceWorkerContextCore when Plznavigate was enabled. This CL ensures that we always add a ServiceWorkerProviderHost to the context. Not doing so could result in a renderer kill later if the page tries to register a ServiceWorker. BUG=703972 Review-Url: https://codereview.chromium.org/2774513003 Cr-Commit-Position: refs/heads/master@{#459239} Committed: https://chromium.googlesource.com/chromium/src/+/991a617bca1c8353bafa7ae0296a9c64c09b023f

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -3 lines) Patch
M content/browser/service_worker/service_worker_dispatcher_host.cc View 1 chunk +8 lines, -3 lines 2 comments Download

Messages

Total messages: 23 (14 generated)
clamy
@falken: PTAL
3 years, 9 months ago (2017-03-23 16:41:26 UTC) #5
clamy
+nasko
3 years, 9 months ago (2017-03-23 16:51:26 UTC) #7
jam
Even though I'm not an expert in this code, this seems like the right fix ...
3 years, 9 months ago (2017-03-23 17:37:09 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2774513003/1
3 years, 9 months ago (2017-03-23 17:37:50 UTC) #13
commit-bot: I haz the power
Try jobs failed on following builders: win_clang on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_clang/builds/192980)
3 years, 9 months ago (2017-03-23 19:04:38 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2774513003/1
3 years, 9 months ago (2017-03-23 20:55:03 UTC) #17
commit-bot: I haz the power
Committed patchset #1 (id:1) as https://chromium.googlesource.com/chromium/src/+/991a617bca1c8353bafa7ae0296a9c64c09b023f
3 years, 9 months ago (2017-03-23 21:54:21 UTC) #20
michaeln
https://codereview.chromium.org/2774513003/diff/1/content/browser/service_worker/service_worker_dispatcher_host.cc File content/browser/service_worker/service_worker_dispatcher_host.cc (right): https://codereview.chromium.org/2774513003/diff/1/content/browser/service_worker/service_worker_dispatcher_host.cc#newcode1020 content/browser/service_worker/service_worker_dispatcher_host.cc:1020: if (provider_host == nullptr) { Do we know how ...
3 years, 9 months ago (2017-03-23 22:25:08 UTC) #22
clamy
3 years, 8 months ago (2017-04-05 12:23:48 UTC) #23
Message was sent while issue was closed.
https://codereview.chromium.org/2774513003/diff/1/content/browser/service_wor...
File content/browser/service_worker/service_worker_dispatcher_host.cc (right):

https://codereview.chromium.org/2774513003/diff/1/content/browser/service_wor...
content/browser/service_worker/service_worker_dispatcher_host.cc:1020: if
(provider_host == nullptr) {
On 2017/03/23 22:25:07, michaeln wrote:
> Do we know how this happens?
> 
> The only way to get an IsBrowserAssignedProviderId is thru 
> ServiceWorkerRequestHandler::InitializeForNavigation() which calls thru to
> PreCreateNavigationHost().
> 
> There's a great comment in service_worker_navigation_handle.h, do we know
where
> that control flows off course in this bug's case?
> 
> // This class is used to manage the lifetime of ServiceWorkerProviderHosts
> // created during navigation. This is a UI thread class, with a pendant class
> // on the IO thread, the ServiceWorkerNavigationHandleCore.
> //
> // The lifetime of the ServiceWorkerNavigationHandle, the
> // ServiceWorkerNavigationHandleCore and the ServiceWorkerProviderHost are the
> // following :
> //   1) We create a ServiceWorkerNavigationHandle on the UI thread with a
> //   service worker provider id of -1. This also leads to the creation of a
> //   ServiceWorkerNavigationHandleCore with an id of -1.
> //
> //   2) When the navigation request is sent to the IO thread, we include a
> //   pointer to the ServiceWorkerNavigationHandleCore.
> //
> //   3) If we pre-create a ServiceWorkerProviderHost for this navigation, its
> //   ownershipped is passed to the ServiceWorkerNavigationHandleCore. The
> //   ServiceWorkerNavigationHandleCore id is updated.
> //
> //   4) The ServiceWorkerNavigationHandleCore informs the
> //   ServiceWorkerNavigationHandle on the UI that the service worker provider
> //   id was updated.
> //
> //   5) When the navigation is ready to commit, the NavigationRequest will
> //   update the RequestNavigationParams based on the id from the
> //   ServiceWorkerNavigationHandle.
> //
> //   6) If the commit leads to the creation of a ServiceWorkerNetworkProvider
> //   in the renderer, a ServiceWorkerHostMsg_ProviderCreated will be received
> //   in the browser. The ServiceWorkerDispatcherHost will retrieve the
> //   ServiceWorkerProviderHost from the ServiceWorkerNavigationHandleCore and
> //   put it in the ServiceWorkerContextCore map of ServiceWorkerProviderHosts.
> //
> //   7) When the navigation finishes, the ServiceWorkerNavigationHandle is
> //   destroyed. The destructor of the ServiceWorkerNavigationHandle posts a
> //   task to destroy the ServiceWorkerNavigationHandleCore on the IO thread.
> //   This in turn leads to the destruction of an unclaimed
> //   ServiceWorkerProviderHost.

My personal hunch (I haven't been able to reproduce that in practice), is that
this is due to some issues we have where the NavigationHandle gets deleted when
it shouldn't. Until the renderer claims the ServiceWorkerProviderHost, it is
actually owned by the NavigationHandle through NavigationHandle's ownership of
of the ServiceWorkerNavigationHandle. So if the NavigationHandle goes away
before the pre-created SWPH is claimed, the SWPH will be deleted. We have a few
race conditions where the NavigationHandle is wrongly deleted before commit.
They could result in the SWPH being deleted before we get OnproviderCreated IPC
from the renderer.

Powered by Google App Engine
This is Rietveld 408576698