New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 616502 link

Starred by 8 users

Issue metadata

Status: WontFix
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Feature

Blocking:
issue 638827
issue 640132



Sign in to add a comment

Speculatively start Service Workers on UI-events

Project Member Reported by horo@chromium.org, Jun 1 2016

Issue description

According to the UMAs, starting up SW takes several hundred milliseconds.

https://crbug.com/561209#c14
> SW startup on the beta channel M51. Android/Win (ms):
> 50p: 222.7/46.48
> 75p: 400.0/91.44
> 95p: 1467/867.9
> 99p: 4230/6135

It typically takes 100ms from mousedown to click event, and 300ms from mouseover to click event. ( https://crbug.com/234036#c1 )
So if we can start SW on those events, we can hide the startup latency.

I'd like to implement this feature behind flag first.
And then we will measure the impact.
 

Comment 1 by horo@chromium.org, Jun 1 2016

WIP patch is here: https://codereview.chromium.org/2000063005/

Comment 2 by horo@chromium.org, Jun 1 2016

Cc: kouhei@chromium.org

Comment 3 by n...@fb.com, Jun 1 2016

Labels: DevRel-Facebook
Another alternative we've discussed in the past is to start processes for SW-matching URLs on hover. It isn't clear that we even need to wait until mouse/tap-down (although that may be the best we can do on mobile for some time).

Comment 5 by horo@chromium.org, Jun 6 2016

According to the previous study (Issue 240959), the precision of mouseover -> click is very low.	
goo.gl/nOaWni, goo.gl/gf9nX1
So I think it is too aggressive to start SW on mouseover.

Comment 6 Deleted

Cueing on mouse/tap down as a first step is a good idea.

From talking a bit with Kouhei on his past experiment with mouseover, it appears that the poor precision of mouseover can be explained by too many transient events occurring as the user tries to reach for something else. So, if the extra 200ms are appealing, we might want to explore a finer detection* of an intentful mouseover.

*: velocity of the pointer, minimal hovering duration... 
Do you plan to write-up a short doc that gives summary about the motivation why we work on this a brief plan, timeline, metrics to watch, pros/cons you've considered?  Most of these are mentioned / discussed in several places but gathering all in a doc'd give clearer context / view to reviewers and leads in other teams.
Project Member

Comment 9 by bugdroid1@chromium.org, Jun 9 2016

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

commit dc54e7bda1c339def75e712235e166ab575d41b7
Author: horo <horo@chromium.org>
Date: Thu Jun 09 08:16:45 2016

Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA.

We can measure the effect of the speculatively launch of Service Workers on UI-events by this metric.

BUG= 616502 

Review-Url: https://codereview.chromium.org/2039743003
Cr-Commit-Position: refs/heads/master@{#398814}

[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/background_sync/background_sync_manager.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/devtools/protocol/service_worker_handler.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance_unittest.cc
[add] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_status.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_test_helper.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_core.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_observer.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_watcher.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_watcher.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_fetch_dispatcher.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_info.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_info.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_internals_ui.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_job_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_provider_host.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_register_job.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_registration.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_url_request_job.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_url_request_job.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/content_browser.gypi
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/tools/metrics/histograms/histograms.xml

Comment 10 by horo@chromium.org, Jun 9 2016

kinuko@
Yes, I wrote a document about this feature.
https://docs.google.com/document/d/1dx3M-L4K6jWTSG3yvnZJjdTIBwl0I27tMh9yZ4rRdrw/edit#
#10- thanks! Will take a look (at the doc and then patch)
Project Member

Comment 12 by bugdroid1@chromium.org, Jun 15 2016

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

commit dc54e7bda1c339def75e712235e166ab575d41b7
Author: horo <horo@chromium.org>
Date: Thu Jun 09 08:16:45 2016

Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA.

We can measure the effect of the speculatively launch of Service Workers on UI-events by this metric.

BUG= 616502 

Review-Url: https://codereview.chromium.org/2039743003
Cr-Commit-Position: refs/heads/master@{#398814}

[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/background_sync/background_sync_manager.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/devtools/protocol/service_worker_handler.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_instance_unittest.cc
[add] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_status.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/embedded_worker_test_helper.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_core.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_observer.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_watcher.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_context_watcher.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_fetch_dispatcher.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_info.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_info.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_internals_ui.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_job_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_provider_host.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_register_job.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_registration.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_url_request_job.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_url_request_job.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version.h
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/browser/service_worker/service_worker_version_unittest.cc
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/content/content_browser.gypi
[modify] https://crrev.com/dc54e7bda1c339def75e712235e166ab575d41b7/tools/metrics/histograms/histograms.xml

Project Member

Comment 13 by bugdroid1@chromium.org, Jun 22 2016

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

commit cca7ec0e84c6ea291d90a79bfdcbcd5f0a55d612
Author: horo <horo@chromium.org>
Date: Wed Jun 22 07:40:20 2016

Speculatively launch Service Workers on mouse/touch events. [1/5]

1/5: Introduce NavigationHintSender.
     This CL.
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     https://codereview.chromium.org/2043083002/
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     https://codereview.chromium.org/2052613003/
4/5: Measure the precision of the speculative launch of Service Workers for NavigationHints
     https://codereview.chromium.org/2045153003/
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     https://codereview.chromium.org/2053573002/

We will introduces a new feature named "SpeculativeLaunchServiceWorker".
When the feature is enabled, HTMLAnchorElement will have NavigationHintSender.
It is similar to PrefetchEventHandler which was removed by https://codereview.chromium.org/344133002.

When HTMLAnchorElement receives mousedown events for the left button or gesturetapunconfirmed or gestureshowpress events, a NavigationHint IPC message will be sent to the browser process.

IPC related code is in [2/5] https://codereview.chromium.org/2043083002/

BUG= 616502 

Review-Url: https://codereview.chromium.org/2043863003
Cr-Commit-Position: refs/heads/master@{#401225}

[modify] https://crrev.com/cca7ec0e84c6ea291d90a79bfdcbcd5f0a55d612/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
[modify] https://crrev.com/cca7ec0e84c6ea291d90a79bfdcbcd5f0a55d612/third_party/WebKit/Source/core/html/HTMLAnchorElement.h

Project Member

Comment 14 by bugdroid1@chromium.org, Jul 25 2016

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

commit 133f8c0b69c28928dfbd0d73ea85740da9712791
Author: horo <horo@chromium.org>
Date: Mon Jul 25 02:41:56 2016

Speculatively launch Service Workers on mouse/touch events. [2/5]

1/5: Introduce NavigationHintSender.
     https://codereview.chromium.org/2043863003/
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     Thic CL.
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     https://codereview.chromium.org/2052613003/
4/5: Measure the precision of the speculative launch of Service Workers for NavigationHints
     https://codereview.chromium.org/2045153003/
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     https://codereview.chromium.org/2053573002/

NavigationHints are sent from NavigationHintSender to ChromeRenderMessageFilter.

NavigationHintSender::maybeSendNavigationHint()
-> sendNavigationHint()
-> WebPrescientNetworking::sendNavigationHint()
-> PrescientNetworkingDispatcher::sendNavigationHint()
-> IPC (NetworkHintsMsg_NavigationHint)

In the browser process, ChromeRenderMessageFilter receives the IPC message.

BUG= 616502 

Review-Url: https://codereview.chromium.org/2043083002
Cr-Commit-Position: refs/heads/master@{#407399}

[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/chrome/browser/renderer_host/chrome_render_message_filter.cc
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/chrome/browser/renderer_host/chrome_render_message_filter.h
[add] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/components/network_hints/common/OWNERS
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/components/network_hints/common/network_hints_messages.h
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/components/network_hints/renderer/prescient_networking_dispatcher.cc
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/components/network_hints/renderer/prescient_networking_dispatcher.h
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/Source/platform/network/NetworkHints.cpp
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/Source/platform/network/NetworkHints.h
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/public/blink_headers.gypi
[add] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/public/platform/WebNavigationHintType.h
[modify] https://crrev.com/133f8c0b69c28928dfbd0d73ea85740da9712791/third_party/WebKit/public/platform/WebPrescientNetworking.h

Status: Started (was: Assigned)
Project Member

Comment 16 by bugdroid1@chromium.org, Jul 25 2016

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

commit 36986071183bdb219186aa9f63f9ee4b162d91b9
Author: horo <horo@chromium.org>
Date: Mon Jul 25 16:00:19 2016

Stop passing const-reference of SWRegistration in all GetRegistrationsCallbacks.

BUG= 616502 

Review-Url: https://codereview.chromium.org/2181553003
Cr-Commit-Position: refs/heads/master@{#407487}

[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/background_sync/background_sync_browsertest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/background_sync/background_sync_manager.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/background_sync/background_sync_manager.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/background_sync/background_sync_manager_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/background_sync/background_sync_service_impl_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/devtools/protocol/service_worker_handler.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/loader/navigation_url_loader_impl_core.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/loader/navigation_url_loader_impl_core.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/notifications/notification_event_dispatcher_impl.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/notifications/notification_message_filter.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/notifications/notification_message_filter.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/push_messaging/push_messaging_router.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/push_messaging/push_messaging_router.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/foreign_fetch_request_handler.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/foreign_fetch_request_handler.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_context_core.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_context_core.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_context_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_controllee_request_handler.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_controllee_request_handler.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_dispatcher_host.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_job_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_register_job.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_register_job.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_storage.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_storage.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_storage_unittest.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_unregister_job.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_unregister_job.h
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9/content/browser/service_worker/service_worker_version.h

Project Member

Comment 17 by bugdroid1@chromium.org, Jul 26 2016

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

commit 2cba6671596841c77457423e70e9d12070425dd1
Author: horo <horo@chromium.org>
Date: Tue Jul 26 03:09:43 2016

Speculatively launch Service Workers on mouse/touch events. [3/5]

1/5: Introduce NavigationHintSender.
     https://codereview.chromium.org/2043863003/
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     https://codereview.chromium.org/2043083002/
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     This CL.
4/5: Measure the precision of the speculative launch of Service Workers for
NavigationHints
     https://codereview.chromium.org/2045153003/
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     https://codereview.chromium.org/2053573002/

When ChromeRenderMessageFilter receives NavigationHint IPC message, it calls
ServiceWorkerContextWrapper::StartServiceWorkerForNavigationHint().
ServiceWorkerContextWrapper will try to start a Service Worker for the document
which is linked from the anchor element.

This CL depends on https://codereview.chromium.org/2181553003/

BUG= 616502 

Review-Url: https://codereview.chromium.org/2052613003
Cr-Commit-Position: refs/heads/master@{#407695}

[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/chrome/browser/chrome_content_browser_client.cc
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/chrome/browser/renderer_host/chrome_render_message_filter.cc
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/chrome/browser/renderer_host/chrome_render_message_filter.h
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/browser/DEPS
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/content/public/browser/service_worker_context.h
[modify] https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1/tools/metrics/histograms/histograms.xml

Cc: esprehn@chromium.org
Might be good to look at this from the architecture perspective. I am guessing using mojo would make the plumbing easier?

Also, are y'all coordinating this work with the PlzNavigate/Paris folks? They might have similar needs/requirements.
Project Member

Comment 19 by bugdroid1@chromium.org, Jul 26 2016

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

commit 0ffd7bda4112522805100efa554bdb7621de860b
Author: dominickn <dominickn@chromium.org>
Date: Tue Jul 26 05:36:50 2016

Revert of Stop passing const-reference of SWRegistration in all GetRegistrationsCallbacks. (patchset #4 id:80001 of https://codereview.chromium.org/2181553003/ )

Reason for revert:
Speculative revert to see if this caused  crbug.com/631190 . App banners use methods touched by this CL to check if a service worker is registered; this is the only relevant-looking CL in the blamelist for the app banner data fetcher tests starting to fail on the Win7 SP1 bot.

This CL will be relanded if re-enabling the disabled app banner data fetcher tests still causes failures on https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29

Original issue's description:
> Stop passing const-reference of SWRegistration in all GetRegistrationsCallbacks.
>
> BUG= 616502 
>
> Committed: https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9
> Cr-Commit-Position: refs/heads/master@{#407487}

TBR=nhiroki@chromium.org,peter@chromium.org,dgozman@chromium.org,mmenke@chromium.org,jkarlin@chromium.org,horo@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 616502 

Review-Url: https://codereview.chromium.org/2183783002
Cr-Commit-Position: refs/heads/master@{#407715}

[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/background_sync/background_sync_browsertest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/background_sync/background_sync_manager.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/background_sync/background_sync_manager.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/background_sync/background_sync_manager_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/background_sync/background_sync_service_impl_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/devtools/protocol/service_worker_handler.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/loader/navigation_url_loader_impl_core.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/loader/navigation_url_loader_impl_core.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/notifications/notification_event_dispatcher_impl.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/notifications/notification_message_filter.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/notifications/notification_message_filter.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/push_messaging/push_messaging_router.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/push_messaging/push_messaging_router.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/foreign_fetch_request_handler.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/foreign_fetch_request_handler.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_context_core.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_context_core.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_context_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_controllee_request_handler.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_controllee_request_handler.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_dispatcher_host.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_job_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_register_job.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_register_job.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_storage.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_storage.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_storage_unittest.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_unregister_job.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_unregister_job.h
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/0ffd7bda4112522805100efa554bdb7621de860b/content/browser/service_worker/service_worker_version.h

Comment 20 by horo@chromium.org, Jul 26 2016

Cc: clamy@chromium.org csharrison@chromium.org
> Might be good to look at this from the architecture perspective. I am guessing using mojo would make the plumbing easier?

csharrison@ is working on the mojofication of the resource hint IPCs.
https://codereview.chromium.org/2043753002/

> Also, are y'all coordinating this work with the PlzNavigate/Paris folks? They might have similar needs/requirements.
+CC:clamy@
In the current design, we speculatively start the ServiceWorker only when the existing render process is suitable (RenderProcessHostImpl::IsSuitableHost() returns true) for the next page.
So I think this speculative feature doesn't disturb PlzNavigate.

clamy@
Do you have any plan to use those navigation UI-event hints for PlzNavigate?
Cc: pasko@chromium.org
+pasko@ for the prerender/nostateprefetch contexts, any opportunities for simplifying or leveraging this sort of approach in a holistic way instead of one-offs?
Project Member

Comment 22 by bugdroid1@chromium.org, Jul 26 2016

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

commit 519e054087b8d7ab72126075040bb7c819c3d007
Author: horo <horo@chromium.org>
Date: Tue Jul 26 10:43:05 2016

Stop passing const-reference of SWRegistration in all GetRegistrationsCallbacks.

BUG= 616502 

Committed: https://crrev.com/36986071183bdb219186aa9f63f9ee4b162d91b9
Review-Url: https://codereview.chromium.org/2181553003
Cr-Original-Commit-Position: refs/heads/master@{#407487}
Cr-Commit-Position: refs/heads/master@{#407761}

[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/background_sync/background_sync_browsertest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/background_sync/background_sync_manager.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/background_sync/background_sync_manager.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/background_sync/background_sync_manager_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/background_sync/background_sync_service_impl_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/devtools/protocol/service_worker_handler.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/loader/navigation_url_loader_impl_core.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/loader/navigation_url_loader_impl_core.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/notifications/notification_event_dispatcher_impl.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/notifications/notification_message_filter.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/notifications/notification_message_filter.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/push_messaging/push_messaging_router.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/push_messaging/push_messaging_router.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/foreign_fetch_request_handler.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/foreign_fetch_request_handler.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_context_core.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_context_core.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_context_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_controllee_request_handler.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_controllee_request_handler.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_dispatcher_host.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_dispatcher_host.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_job_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_register_job.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_register_job.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_storage.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_storage.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_storage_unittest.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_unregister_job.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_unregister_job.h
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/519e054087b8d7ab72126075040bb7c819c3d007/content/browser/service_worker/service_worker_version.h

Project Member

Comment 23 by bugdroid1@chromium.org, Jul 26 2016

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

commit 56f30b7653eff769a4d39d92f8131f5e9f72f0c6
Author: horo <horo@chromium.org>
Date: Tue Jul 26 12:12:07 2016

Speculatively launch Service Workers on mouse/touch events. [3/5]

1/5: Introduce NavigationHintSender.
     https://codereview.chromium.org/2043863003/
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     https://codereview.chromium.org/2043083002/
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     This CL.
4/5: Measure the precision of the speculative launch of Service Workers for
NavigationHints
     https://codereview.chromium.org/2045153003/
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     https://codereview.chromium.org/2053573002/

When ChromeRenderMessageFilter receives NavigationHint IPC message, it calls
ServiceWorkerContextWrapper::StartServiceWorkerForNavigationHint().
ServiceWorkerContextWrapper will try to start a Service Worker for the document
which is linked from the anchor element.

This CL depends on https://codereview.chromium.org/2181553003/

BUG= 616502 

Committed: https://crrev.com/2cba6671596841c77457423e70e9d12070425dd1
Review-Url: https://codereview.chromium.org/2052613003
Cr-Original-Commit-Position: refs/heads/master@{#407695}
Cr-Commit-Position: refs/heads/master@{#407775}

[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/chrome/browser/chrome_content_browser_client.cc
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/chrome/browser/renderer_host/chrome_render_message_filter.cc
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/chrome/browser/renderer_host/chrome_render_message_filter.h
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/browser/DEPS
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/content/public/browser/service_worker_context.h
[modify] https://crrev.com/56f30b7653eff769a4d39d92f8131f5e9f72f0c6/tools/metrics/histograms/histograms.xml

Project Member

Comment 24 by bugdroid1@chromium.org, Aug 3 2016

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

commit b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb
Author: horo <horo@chromium.org>
Date: Wed Aug 03 02:22:37 2016

Speculatively launch Service Workers on mouse/touch events. [4/5]

1/5: Introduce NavigationHintSender.
     https://codereview.chromium.org/2043863003/
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     https://codereview.chromium.org/2043083002/
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     https://codereview.chromium.org/2052613003/
4/5: Measure the precision of the speculative launch of Service Workers for
NavigationHints
     This CL.
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     https://codereview.chromium.org/2053573002/

This CL introduces "ServiceWorker.NavigationHintPrecision" UMA to measure the
precision of the speculative launch of Service Workers for navigation hints.
It is recorded when the speculatively launched worker is stopped.
If there was no event fetched to the worker, this value is false.
This means that the speculative launch was meaningless.

BUG= 616502 

Review-Url: https://codereview.chromium.org/2045153003
Cr-Commit-Position: refs/heads/master@{#409436}

[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/content/browser/service_worker/service_worker_version.h
[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/content/browser/service_worker/service_worker_version_unittest.cc
[modify] https://crrev.com/b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb/tools/metrics/histograms/histograms.xml

Cc: droger@chromium.org lizeb@chromium.org mattcary@chromium.org
re #18: Let's hear from clamy@ when she gets back from vacation. My naive understanding is that whenever RenderProcessHostImpl::Something is involved, it will probably add tax for PlzNavigate.

re #21: We've been considering speculative creation of SW for other usecases (CustomTabs/AMP), but have not thought out the best architecture for it yet.

I think SW one-offs are good at this point when there are clear wins. A "clear win" would mean SW is starting earlier only when it is guaranteed that that the navigation will happen, and will need a new service worker, and cannot reuse the existing, etc.). I am not sure the approach horo@ is taking would provide these guarantees, would be interesting to hear more details.

On simplifying: a way to simplify that I can think of is to have a central place in chrome/ to get notified about various signals and decide/coordinate what speculative actions to take. This would help cases like avoiding preconnects to something that is fully in cache, doing a DNS resolution for something that is overridden by SW, etc. This is not particularly a simplification in code, more like a simplification of a way to design A/B experiments and make gradual improvements.

We did not have cycles for centralizing predictive actions in Q3 though, and with that I am not sure we can simplify anything at this point.

On holistic approach: **yes please**. How is this going to be tested given that there are not too many SW-enabled websites? Would a field study have enough data?

Can we please start such efforts from the design of the experiment that is realistic and representative (and hopefully able to spot regressions in the long run)? I imagine after the experiment design is done we can get into details of what needs to be done to make the improvement significant.

Spending months on something that gets inconclusive data and then being super-unmotivated to revert all the changes back to something simpler .. is something that slows down everyone, not only a specific team working on a specific improvement.
A few things to note...

In short: this change is surely being made as a kind of one-off experimental optimization for SW, but non-SW plumbing part is pretty small and is coded as generic network hint, so it should be easy to rearchitect / integrate the code that is added by this change into our new pre* architecture.  To be more specific:

* Mojo-ification: as horo@ mentioned it should be able to be done together with migration of other network hint IPC, which is being worked on by csharrison@ (actually I'm one of the people who's blocking this work).  We also have clear TODO in the new code to migrate soonish too.

* Speculative action coordination / holistic approach: The new pre* hint code being added is fairly generic, it should be relatively easy to integrate the current code into the coming coordination mechanism.

* Measurement / testing plan: Horo has written a short write-up which briefly describes the motivation, past attempts and measurement plan.  It's not too detailed but gives some necessary info for these points: https://docs.google.com/document/d/1dx3M-L4K6jWTSG3yvnZJjdTIBwl0I27tMh9yZ4rRdrw/edit#

(horo: the doc doesn't really say if we're running this behind a flag / in an way where we can do A/B type comparison, while I was assuming we'd be doing so. Are we planning to do that, and if so can we more clearly document it in the doc?)

For this particular optimization work I think it'd be probably easier / practical to just experiment this and revert the work if it doesn't seem to work rather than spending long time to think about complete experiment plan and generic pre* coordination approach. (While I tend to say the opposite whenever we need to make complex changes in the generic loading code base, I think we're happy to refine our experiment / measurement plan)

For the relationship with PlzNavigate I'm not too sure, I'd like to hear from clamy@ too.  (But I think we could discuss integration plan after we have some experimental results too)


I think we are in agreement, but just to confirm: speculative action coordinator idea is mostly orthogonal to this effort, I think it is good not to be blocked on the coordinator for speculative optimizations like this at the moment.
Yep. Sounds good!

Comment 29 by horo@chromium.org, Aug 4 2016

I wrote the information about the flag and the experiment framework in the document.
And I wrote about the new UMAs to measure the negative impact on the smoothness of scrolling.
https://codereview.chromium.org/2211783003/
- Event.Latency.TouchToFirstScrollUpdateSwapBegin.IsRunningNavigationHintTask
- Event.Latency.TouchToScrollUpdateSwapBegin.IsRunningNavigationHintTask


Project Member

Comment 30 by bugdroid1@chromium.org, Aug 8 2016

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

commit eb269387e90b272408235bef800ad6eb113c4f40
Author: horo <horo@chromium.org>
Date: Mon Aug 08 03:31:03 2016

Speculatively launch Service Workers on mouse/touch events. [5/5]

1/5: Introduce NavigationHintSender.
     https://codereview.chromium.org/2043863003/
2/5: Pipe NavigationHints from NavigationHintSender to ChromeRenderMessageFilter
     https://codereview.chromium.org/2043083002/
3/5: Call StartServiceWorkerForNavigationHint() from ChromeRenderMessageFilter
     https://codereview.chromium.org/2052613003/
4/5: Measure the precision of the speculative launch of Service Workers for
NavigationHints
     https://codereview.chromium.org/2045153003/
5/5: Add flags to enable SupeculativeLaunchServiceWorker
     This CL.

This CL introduces a new feature named "SpeculativeLaunchServiceWorker".
When the feature is enabled, Service Workers are speculatively started on the
user's mousedown/touch events.
Demo:
https://drive.google.com/file/d/0B6skYAFVnosEMWdzRm4yMEtIMkk/view?usp=sharing

BUG= 616502 

Review-Url: https://codereview.chromium.org/2053573002
Cr-Commit-Position: refs/heads/master@{#410295}

[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/chrome/app/generated_resources.grd
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/chrome/browser/about_flags.cc
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/chrome/browser/chrome_service_worker_browsertest.cc
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/content/child/runtime_features.cc
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/content/public/common/content_features.cc
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/content/public/common/content_features.h
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/third_party/WebKit/public/web/WebRuntimeFeatures.h
[modify] https://crrev.com/eb269387e90b272408235bef800ad6eb113c4f40/tools/metrics/histograms/histograms.xml

Comment 31 by clamy@chromium.org, Aug 16 2016

From what I understand, this should be orthogonal to PlzNavigate. The issue we have with PlzNavigate is properly setting up the plumbing from the loading code to the ServiceWorker, not starting the SW itself.

Just a question: could it lead to extra-processes being spawn up because of this during cross-site navigations? IIUC we would normally use the pending renderer process for the SW in this case. There could we end up creating a process for the SW before we have created the pending one, which means we would create yet another one when we actually start the navigation?

Comment 32 by horo@chromium.org, Aug 16 2016

> Just a question: could it lead to extra-processes being spawn up because of this during cross-site navigations? IIUC we would normally use the pending renderer process for the SW in this case. There could we end up creating a process for the SW before we have created the pending one, which means we would create yet another one when we actually start the navigation?

No. It doesn't spawn a new process. It tries to use the existing renderer process from which the navigation hint was sent.
If the existing one is not suitable for loading the next page, StartServiceWorkerForNavigationHint() fails.
https://cs.chromium.org/chromium/src/content/public/browser/service_worker_context.h?rcl=0&l=117

Comment 33 by horo@chromium.org, Aug 18 2016

Blocking: 638827
Project Member

Comment 34 by bugdroid1@chromium.org, Aug 19 2016

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

commit f5d309f062b41c29a2adbcc469a967b95f61dca3
Author: horo <horo@chromium.org>
Date: Fri Aug 19 00:47:07 2016

Track input latency while starting a ServiceWorker for a navigation hint.

This CL introduces these new UMAs:
- Event.Latency.TouchToFirstScrollUpdateSwapBegin.IsRunningNavigationHintTask
- Event.Latency.TouchToScrollUpdateSwapBegin.IsRunningNavigationHintTask

BUG= 616502 ,  638827 

Review-Url: https://codereview.chromium.org/2211783003
Cr-Commit-Position: refs/heads/master@{#412998}

[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/renderer_host/input/render_widget_host_latency_tracker.h
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/renderer_host/render_widget_host_impl.cc
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3/tools/metrics/histograms/histograms.xml

Comment 35 by horo@chromium.org, Aug 23 2016

The names of UMA in the cl description are wrong.

The correct names are:
- Event.Latency.TouchToFirstScrollUpdateSwapBegin_IsRunningNavigationHintTask
- Event.Latency.TouchToScrollUpdateSwapBegin_IsRunningNavigationHintTask

Comment 36 by horo@chromium.org, Aug 23 2016

Note:
$ git find-releases f5d309f062b41c29a2adbcc469a967b95f61dca3
commit f5d309f062b41c29a2adbcc469a967b95f61dca3 was:
  initially in 54.0.2833.0

Project Member

Comment 37 by bugdroid1@chromium.org, Aug 25 2016

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

commit a7e7439065dd32570ac2aabaf5557470294a43c0
Author: horo <horo@chromium.org>
Date: Thu Aug 25 08:36:22 2016

Add navigation hint ServiceWorkerMetrics.EventType enums in histograms.xml

I had to add them in https://codereview.chromium.org/2052613003

BUG= 616502 

Review-Url: https://codereview.chromium.org/2276863002
Cr-Commit-Position: refs/heads/master@{#414363}

[modify] https://crrev.com/a7e7439065dd32570ac2aabaf5557470294a43c0/tools/metrics/histograms/histograms.xml

Comment 38 by horo@chromium.org, Oct 4 2016

We found a bug in the logic of this speculative launch.
Currently when the user mouse down / tap down a link, we launch the SW even if the SW doesn't have any FetchEvent handler.
So we are launching in vain.

We have to check fetch_handler_existence() in ServiceWorkerContextWrapper::DidFindRegistrationForNavigationHint.
Project Member

Comment 39 by bugdroid1@chromium.org, Oct 4 2016

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

commit c2ace594258d2912d8732b263aabb13594fed912
Author: horo <horo@chromium.org>
Date: Tue Oct 04 15:08:38 2016

Don't speculatively start ServiceWorker if it doesn't have FetchEvent handler

ServiceWorkers without FetchEvent handlers should not be started up on navigation, see  https://crbug.com/616502#c38 

BUG= 616502 ,640132

Review-Url: https://codereview.chromium.org/2393503002
Cr-Commit-Position: refs/heads/master@{#422796}

[modify] https://crrev.com/c2ace594258d2912d8732b263aabb13594fed912/chrome/browser/chrome_service_worker_browsertest.cc
[modify] https://crrev.com/c2ace594258d2912d8732b263aabb13594fed912/content/browser/service_worker/service_worker_context_wrapper.cc

Comment 40 by horo@chromium.org, Oct 11 2016

Memo:
$ git find-releases c2ace594258d2912d8732b263aabb13594fed912
commit c2ace594258d2912d8732b263aabb13594fed912 was:
  initially in 55.0.2881.0

Project Member

Comment 41 by bugdroid1@chromium.org, Dec 8 2016

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

commit b7ebb2a06b4074b7fb9ecd3ef03d307321c5e910
Author: horo <horo@chromium.org>
Date: Thu Dec 08 15:46:33 2016

Introduce ServiceWorker.MainFramePageLoad.CoreTransition and RedirectChainLength UMAs.

The result of the experiment of Speculative launch Service Workers was not so good as we thought.
We think this is because:
 - Low percentage of navigations by link click
 - High percentage of navigations with redirects

To confirm this, I'd like to introduce 2 UMAs.
 - ServiceWorker.MainFramePageLoad.CoreTransition
 - ServiceWorker.MainFramePageLoad.RedirectChainLength

BUG= 616502 

Review-Url: https://codereview.chromium.org/2551013003
Cr-Commit-Position: refs/heads/master@{#437250}

[modify] https://crrev.com/b7ebb2a06b4074b7fb9ecd3ef03d307321c5e910/content/browser/service_worker/service_worker_controllee_request_handler.cc
[modify] https://crrev.com/b7ebb2a06b4074b7fb9ecd3ef03d307321c5e910/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/b7ebb2a06b4074b7fb9ecd3ef03d307321c5e910/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/b7ebb2a06b4074b7fb9ecd3ef03d307321c5e910/tools/metrics/histograms/histograms.xml

Project Member

Comment 42 by bugdroid1@chromium.org, Mar 29 2017

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

commit a9acfbde04faff434f737608a7f6632d6e4b69e8
Author: horo <horo@chromium.org>
Date: Wed Mar 29 06:22:11 2017

Revert "Track input latency while starting a ServiceWorker for a navigation hint."

The NavigationHint experiment finished.

This CL reverts commit
 https://crrev.com/f5d309f062b41c29a2adbcc469a967b95f61dca3
 https://codereview.chromium.org/2211783003

BUG= 616502 ,  638827 

Review-Url: https://codereview.chromium.org/2776933004
Cr-Commit-Position: refs/heads/master@{#460299}

[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/renderer_host/input/render_widget_host_latency_tracker.h
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/renderer_host/render_widget_host_impl.cc
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/a9acfbde04faff434f737608a7f6632d6e4b69e8/tools/metrics/histograms/histograms.xml

Project Member

Comment 43 by bugdroid1@chromium.org, Mar 29 2017

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

commit 062ef535e5f84efafa48a36a72c43550d964a0a6
Author: horo <horo@chromium.org>
Date: Wed Mar 29 08:16:07 2017

Revert of "Speculatively launch Service Workers on mouse/touch events."

This CL reverts the commits below:
- Speculatively launch Service Workers on mouse/touch events.
  1/5: https://codereview.chromium.org/2043863003/
       cca7ec0e84c6ea291d90a79bfdcbcd5f0a55d612
  2/5: https://codereview.chromium.org/2043083002/
       133f8c0b69c28928dfbd0d73ea85740da9712791
  3/5: https://codereview.chromium.org/2052613003/
       56f30b7653eff769a4d39d92f8131f5e9f72f0c6
  4/5: https://codereview.chromium.org/2045153003/
       b9d6af8dfc9c1bcaabe9d67dd6c30c30b3873cbb
  5/5: https://codereview.chromium.org/2053573002/
       eb269387e90b272408235bef800ad6eb113c4f40
- Don't speculatively start ServiceWorker if it doesn't have FetchEvent handler
  https://codereview.chromium.org/2393503002
  c2ace594258d2912d8732b263aabb13594fed912

BUG= 616502 

Review-Url: https://codereview.chromium.org/2778173002
Cr-Commit-Position: refs/heads/master@{#460326}

[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/about_flags.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/chrome_content_browser_client.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/chrome_service_worker_browsertest.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/flag_descriptions.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/flag_descriptions.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/renderer_host/chrome_render_message_filter.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/chrome/browser/renderer_host/chrome_render_message_filter.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/components/network_hints/common/network_hints_messages.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/components/network_hints/renderer/prescient_networking_dispatcher.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/components/network_hints/renderer/prescient_networking_dispatcher.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/DEPS
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_context_wrapper.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_context_wrapper.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_metrics.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_metrics.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_version.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_version.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/browser/service_worker/service_worker_version_unittest.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/child/runtime_features.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/public/browser/service_worker_context.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/public/common/content_features.cc
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/content/public/common/content_features.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/core/html/HTMLAnchorElement.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/platform/network/NetworkHints.cpp
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/platform/network/NetworkHints.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/Source/web/WebRuntimeFeatures.cpp
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/public/BUILD.gn
[delete] https://crrev.com/47f8634a9cd73ded68ee3e5f2c0de85a868396b0/third_party/WebKit/public/platform/WebNavigationHintType.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/public/platform/WebPrescientNetworking.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/third_party/WebKit/public/web/WebRuntimeFeatures.h
[modify] https://crrev.com/062ef535e5f84efafa48a36a72c43550d964a0a6/tools/metrics/histograms/histograms.xml

Comment 44 by horo@chromium.org, Mar 30 2017

Status: Fixed (was: Started)
Status: WontFix (was: Fixed)
Resetting to WontFix as we decided not to launch this feature.
Blocking: 640132

Sign in to add a comment