New issue
Advanced search Search tips

Issue 778898 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 715640



Sign in to add a comment

S13nServiceWorker: initializing SubresourceLoader for a document and first request from the doc has a race

Project Member Reported by kinuko@chromium.org, Oct 27 2017

Issue description

Currently we set up SubresourceLoader when SetController mojo call is sent from the browser process (this happens right after the renderer informs the browser that the renderer-side provider (serviceWorkerContainer) becomes available), but this has a race.

More context:
https://chromium-review.googlesource.com/c/chromium/src/+/711557#message-1ac0ae87f0403c721f95f443573e230869bd067d

usleep test: https://chromium-review.googlesource.com/c/chromium/src/+/722544


 
Project Member

Comment 1 by bugdroid1@chromium.org, Oct 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/250577cd2932a81168ebd2a714d43911a722c34d

commit 250577cd2932a81168ebd2a714d43911a722c34d
Author: Kinuko Yasuda <kinuko@chromium.org>
Date: Sun Oct 29 02:51:24 2017

Make navigation request handlers pass subresource loader params as a struct

ServiceWorker wants to pass several params for subresource-loader setup
in the renderer that are not URLLoaderFactory, because it needs to create
URLLoaderFactory in the renderer. Currently we pass them via a
separate Mojo call but it causes racy situation and makes tests flaky.

This change introduces SubresourceLoaderParams struct (that has
URLLoaderFactoryInfo as a member) and pass it along from navigation request
handlers instead of URLLoaderFactoryInfo.

This CL also slightly changes how WebUI subresource loader factory is passed;
to make it share more code with AppCache etc.

Bug:  778898 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Iafe0e2f7bd8f6c500c91bde3c46dff3d4d7dd8c8
Reviewed-on: https://chromium-review.googlesource.com/739621
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512415}
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/appcache/appcache_request_handler.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/appcache/appcache_request_handler.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/frame_host/navigation_request.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/frame_host/navigation_request.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/frame_host/navigator_impl.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/frame_host/render_frame_host_impl.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/navigation_url_loader_delegate.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/navigation_url_loader_impl.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/navigation_url_loader_network_service.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/navigation_url_loader_network_service_unittest.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/url_loader_request_handler.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/loader/url_loader_request_handler.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/browser/renderer_host/render_process_host_impl.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/common/BUILD.gn
[add] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/common/navigation_subresource_loader_params.cc
[add] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/common/navigation_subresource_loader_params.h
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/renderer/service_worker/service_worker_subresource_loader.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/test/test_navigation_url_loader.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/test/test_navigation_url_loader_delegate.cc
[modify] https://crrev.com/250577cd2932a81168ebd2a714d43911a722c34d/content/test/test_navigation_url_loader_delegate.h

Comment 2 by kinuko@chromium.org, Oct 30 2017

Cc: falken@chromium.org
I found that several other tests could be a lot flaky with NetworkService, because we don't guarantee the ordering between resource loading and channel-associated messages there.  The initial SetController could come after the document is created, therefore fairly basic test like external/wpt/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html could be flaky.
Project Member

Comment 3 by bugdroid1@chromium.org, Nov 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8757204a797ec6194d5d965f93e875593f2b982d

commit 8757204a797ec6194d5d965f93e875593f2b982d
Author: Kinuko Yasuda <kinuko@chromium.org>
Date: Sat Nov 04 07:50:13 2017

NetworkService: change how AppCache (and SW) provides SubresourceLoaderParams

* Allow request handlers to return a subresource loading parameter
  even when the handler itself doesn't handle the main resource loading.
* This change is necessary to handle the situation where the request
  handler (i.e. AppCache or ServiceWorker) falls back to the network
  for the main resource loading but still wants to control the
  subsequent subresource loading.

This shoudn't change the existing behavior *YET* and all the existing
tests should pass.

This doc has a bit more info:
https://docs.google.com/document/d/1dvvksKQYWEnUdOcjkyreaTOxJD9L4Gybszb5mxrSzHk/

Bug:  778898 ,  715640 ,  715632 
Change-Id: Iad645eefa81c60acb03b78aadf17706e4355af67
Reviewed-on: https://chromium-review.googlesource.com/750746
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514037}
[modify] https://crrev.com/8757204a797ec6194d5d965f93e875593f2b982d/content/browser/appcache/appcache_request_handler.cc
[modify] https://crrev.com/8757204a797ec6194d5d965f93e875593f2b982d/content/browser/appcache/appcache_request_handler.h
[modify] https://crrev.com/8757204a797ec6194d5d965f93e875593f2b982d/content/browser/loader/navigation_url_loader_network_service.cc
[modify] https://crrev.com/8757204a797ec6194d5d965f93e875593f2b982d/content/browser/loader/url_loader_request_handler.h

Comment 4 by laforge@google.com, Nov 7 2017

Components: Internals>Network>Service

Comment 5 by laforge@google.com, Nov 7 2017

Components: -Internals>Network>Service Internals>Services>Network
Apologies, applied the wrong component in bulk.

Comment 6 by kinuko@chromium.org, Nov 15 2017

Cc: shimazu@chromium.org
Per offline chat, let me reassign this to falken@ for now.  Doc and WIP patch are here:

https://docs.google.com/document/d/1dvvksKQYWEnUdOcjkyreaTOxJD9L4Gybszb5mxrSzHk/
https://chromium-review.googlesource.com/c/chromium/src/+/724565

(Feel free to re-assign or assign back to me)

Comment 7 by kinuko@chromium.org, Nov 15 2017

Cc: -falken@chromium.org kinuko@chromium.org
Owner: falken@chromium.org
Status: Assigned (was: Started)
(Sorry, wrong clicks)
Project Member

Comment 8 by bugdroid1@chromium.org, Jan 11 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ba384081c75d1fe07ddcd2be91eb66ade035aeaf

commit ba384081c75d1fe07ddcd2be91eb66ade035aeaf
Author: Kinuko Yasuda <kinuko@chromium.org>
Date: Thu Jan 11 08:30:16 2018

S13nServiceWorker: Send ControllerServiceWorker on navigation commit

To fix the IPC race problem. More details in:
https://docs.google.com/document/d/1dvvksKQYWEnUdOcjkyreaTOxJD9L4Gybszb5mxrSzHk/

- also sends controller_obj_info with pre-created handle ID
- also changes SetController to also send ControllerServiceWorker

The new code doesn't rely on SetController after navigation, therefore
there's no race condition there. Note that currently we still call
SetController in ServiceWorkerProviderHost::CompleteNavigationInitialized
but it's just to update UseCounter. You can see mojo_linux results for
https://chromium-review.googlesource.com/c/chromium/src/+/724565
to verify that all layout tests (except for usecounter one) pass without
calling SetController.

Bug:  778898 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Ie1d15bd3695b636427df6329cc5e07878bd24ee6
Reviewed-on: https://chromium-review.googlesource.com/742961
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528584}
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/loader/navigation_url_loader_network_service.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_controllee_request_handler.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_controllee_request_handler.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_handle.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_handle.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_provider_host.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_provider_host.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_provider_host_unittest.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/browser/service_worker/service_worker_version.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/common/frame.mojom
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/common/navigation_subresource_loader_params.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/common/navigation_subresource_loader_params.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/common/service_worker/controller_service_worker.mojom
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/common/service_worker/service_worker_container.mojom
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/render_frame_impl.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/render_frame_impl.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/controller_service_worker_connector.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/controller_service_worker_connector.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_network_provider.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_network_provider.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_provider_context.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_provider_context.h
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_provider_context_unittest.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_subresource_loader.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/renderer/service_worker/service_worker_subresource_loader_unittest.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/test/test_render_frame.cc
[modify] https://crrev.com/ba384081c75d1fe07ddcd2be91eb66ade035aeaf/content/test/test_render_frame_host.cc

Comment 9 by kinuko@chromium.org, Jan 11 2018

Owner: kinuko@chromium.org
Status: Fixed (was: Assigned)
Project Member

Comment 10 by bugdroid1@chromium.org, Feb 8 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206

commit b950d90a5cf7b2b9353b1c4418d5aeb94e26c206
Author: arthursonzogni <arthursonzogni@chromium.org>
Date: Thu Feb 08 09:27:13 2018

NavigationMojoResponse: SendControllerServiceWorker on navigation commit.

This fix an IPC race problem. More details in the design doc:
https://docs.google.com/document/d/1dvvksKQYWEnUdOcjkyreaTOxJD9L4Gybszb5mxrSzHk/

This was already fixed with S13nServiceWorker by:
https://chromium-review.googlesource.com/742961
This CL does the same with NavigationMojoResponse. In reality it was
simpler here, because it reuses what was done in the previous CL.

Design doc: https://goo.gl/Rrrc7n (NavigationMojoResponse)

Bug:  778898 ,  705744 
Change-Id: I05676fcc0b4aa581f0f575cc6e7c91cc22b8549b
Reviewed-on: https://chromium-review.googlesource.com/899147
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535339}
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/browser/loader/navigation_url_loader_network_service.cc
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/browser/service_worker/service_worker_handle.cc
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/browser/service_worker/service_worker_provider_host.cc
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/browser/service_worker/service_worker_provider_host.h
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/common/frame.mojom
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/renderer/service_worker/service_worker_provider_context.cc
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/content/renderer/service_worker/service_worker_provider_context.h
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/third_party/WebKit/LayoutTests/TestExpectations
[modify] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/third_party/WebKit/LayoutTests/VirtualTestSuites
[add] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/third_party/WebKit/LayoutTests/virtual/navigation-mojo-response/external/wpt/service-workers/service-worker/README.txt
[add] https://crrev.com/b950d90a5cf7b2b9353b1c4418d5aeb94e26c206/third_party/WebKit/LayoutTests/virtual/navigation-mojo-response/http/tests/serviceworker/README.txt

Project Member

Comment 11 by bugdroid1@chromium.org, Feb 13 2018

Labels: merge-merged-3325
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/812faddb42fdf00945568be8fd4ee48206b8af62

commit 812faddb42fdf00945568be8fd4ee48206b8af62
Author: Matt Falkenhagen <falken@chromium.org>
Date: Tue Feb 13 07:06:43 2018

M65: NavigationMojoResponse: SendControllerServiceWorker on navigation commit.

This fix an IPC race problem. More details in the design doc:
https://docs.google.com/document/d/1dvvksKQYWEnUdOcjkyreaTOxJD9L4Gybszb5mxrSzHk/

This was already fixed with S13nServiceWorker by:
https://chromium-review.googlesource.com/742961
This CL does the same with NavigationMojoResponse. In reality it was
simpler here, because it reuses what was done in the previous CL.

Design doc: https://goo.gl/Rrrc7n (NavigationMojoResponse)

(cherry picked from commit b950d90a5cf7b2b9353b1c4418d5aeb94e26c206)

Bug:  778898 ,  705744 
Change-Id: I05676fcc0b4aa581f0f575cc6e7c91cc22b8549b
Reviewed-on: https://chromium-review.googlesource.com/899147
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#535339}
Reviewed-on: https://chromium-review.googlesource.com/914943
Cr-Commit-Position: refs/branch-heads/3325@{#442}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/browser/loader/navigation_url_loader_network_service.cc
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/browser/service_worker/service_worker_handle.cc
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/browser/service_worker/service_worker_provider_host.cc
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/browser/service_worker/service_worker_provider_host.h
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/common/frame.mojom
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/renderer/service_worker/service_worker_provider_context.cc
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/content/renderer/service_worker/service_worker_provider_context.h
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/third_party/WebKit/LayoutTests/TestExpectations
[modify] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/third_party/WebKit/LayoutTests/VirtualTestSuites
[add] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/third_party/WebKit/LayoutTests/virtual/navigation-mojo-response/external/wpt/service-workers/service-worker/README.txt
[add] https://crrev.com/812faddb42fdf00945568be8fd4ee48206b8af62/third_party/WebKit/LayoutTests/virtual/navigation-mojo-response/http/tests/serviceworker/README.txt

Sign in to add a comment