Contact emails
Explainer
None
Specification
https://w3c.github.io/ServiceWorker/#control-and-use-worker-client
> When the fetch is routed through HTTP fetch, the worker client's active service worker is set to the result of the service worker registration matching.
For service worker registration matching:
https://w3c.github.io/ServiceWorker/#scope-match-algorithm
Summary
This change will affect the 2 parts in the behavior of dedicated workers.
Previous behaviors:
1) dedicated workers were not exposed to service workers via the Clients API.
2) dedicated workers were treated as part of their owner document and controlled by the document's service worker regardless of the dedicated worker script URL
New behaviors by this change:
1) dedicated workers will be real service worker clients and they will be exposed via the Clients API.
`Clients.matchAll({‘type’: ‘worker’})` will include dedicated workers. The ‘type’ option is an opt-in option and `Clients.matchAll()` returns only window clients by default.
2) dedicated workers will be controlled by their own service worker matched with the dedicated worker script URL.
New behaviors are aligned with the spec. It is achieved by updating a request for the worker script loading from renderer-initiated to browser-initiated.
Blink component
Blink>Worker
TAG review
None - this has long been part of an established spec, and we are just changing Chromium to follow it
TAG review status
Not applicable
Risks
Interoperability and Compatibility
The first possible risk is that the service worker that controls a dedicated worker may change. In particular:
A dedicated worker was previously controlled by a service worker, and is now uncontrolled.
A dedicated worker was previously not controlled by a service worker, and is now controlled.
A dedicated worker was previously controlled by a service worker, and is now controlled by a different service worker.
The dedicated worker controlled by a service worker is determined based on the scope matching. Previously, if the document matched a service worker’s scope, their child dedicated workers were also controlled. Developers might need to update their service worker scope or dedicated worker’s script path.
The second possible risk is that the behavior in Client and Clients API will change. Shared Worker was already exposed as clients. The changes are specifically:
`Client` with “worker” client type will be exposed. (WPT, wpt.fyi)
Note: The page needs to set 'worker' or 'all' inside the ClientQueryOptions passed matchAll() for dedicated workers to be exposed. This matches the existing behavior for shared workers.
WorkerControlledByServiceWorkerOutOfScope in UseCounter shows the percentage of sites (almost 1%) that currently have a dedicated worker that is incorrectly controlled by a service worker according to the spec. However, this number includes service workers that don’t have a fetch event handler, which will not be broken by this change. We are planning to refine the UseCounter (CL).
Gecko: Positive. Shipped based on the result of WPTs (listed in the “Is this feature fully tested by web-platform-tests?” section)
WebKit: No signal. Not supported yet based on the result of WPTs. Sent "Request for position" to webki...@lists.webkit.org https://lists.webkit.org/pipermail/webkit-dev/ (the email is not listed yet but will appear)
Web developers: Mixed
Positive:
crbug.com/906991 has 14 stars.
Some developers want this feature according to crbug.com/1186571#c3 crbug.com/1190916#c1.
The following issues will be unblocked:
Negative: We know of at least one site (internal) that has an out-of-scope dedicated worker that they need to be controlled for offline support. To avoid breakage, they plan to change their worker script URL to align with this change, while they don't seem to view this change as benefiting them.
Is this feature fully tested by web-platform-tests?
Yes
Some test cases in the following tests will be fixed:
https://wpt.fyi/results/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https.html
https://wpt.fyi/results/service-workers/service-worker/clients-matchall-blob-url-worker.https.html
https://wpt.fyi/results/service-workers/service-worker/clients-get-client-types.https.html
https://wpt.fyi/results/service-workers/service-worker/client-url-of-blob-url-worker.https.html
https://wpt.fyi/results/service-workers/service-worker/local-url-inherit-controller.https.html
https://wpt.fyi/results/service-workers/service-worker/worker-interception.https.html
Tracking bug
https://bugs.chromium.org/p/chromium/issues/detail?id=906991
Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/6591543769038848--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CA%2BvVX0hXrgKy1BZ4E1u%2BQe1xZ8%3DG5AqAzRwNwj29mOR-dYJkNQ%40mail.gmail.com.
Gecko: Positive. Shipped based on the result of WPTs (listed in the “Is this feature fully tested by web-platform-tests?” section)
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw-JCQ107cY4jh0qRQt7t4_4Ra39KH%2BtS9GPZN88Tv8ucA%40mail.gmail.com.
> 1% is quite a lot. It sounds like you are planning to refine the UseCounter to more accurately count cases that might be broken by this change?
Yes, I'm adding the UseCounter, kWorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope. This measures the risk of site breakage by this change.
https://chromium-review.googlesource.com/c/chromium/src/+/2799115
On Mon, Apr 5, 2021 at 1:35 AM Asami Doi <asam...@chromium.org> wrote:> 1% is quite a lot. It sounds like you are planning to refine the UseCounter to more accurately count cases that might be broken by this change?
Yes, I'm adding the UseCounter, kWorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope. This measures the risk of site breakage by this change.
https://chromium-review.googlesource.com/c/chromium/src/+/2799115Just to clarify, it narrows the upper bound on breakage, but still doesn't exactly measure real breakage. For example, many sites will have empty fetch handlers or fetch handlers that don't try to offline worker scripts.
Hi,On Mon, Apr 5, 2021 at 7:43 AM Ben Kelly <wande...@chromium.org> wrote:On Mon, Apr 5, 2021 at 1:35 AM Asami Doi <asam...@chromium.org> wrote:> 1% is quite a lot. It sounds like you are planning to refine the UseCounter to more accurately count cases that might be broken by this change?
Yes, I'm adding the UseCounter, kWorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope. This measures the risk of site breakage by this change.
https://chromium-review.googlesource.com/c/chromium/src/+/2799115Just to clarify, it narrows the upper bound on breakage, but still doesn't exactly measure real breakage. For example, many sites will have empty fetch handlers or fetch handlers that don't try to offline worker scripts.But the new UseCounter will be an upper-bound, right? If it returns a low number then perhaps that's good enough to ship this change. And if not, an analysis of sites that might be broken would be needed.It sounds like we should wait for this new UseCounter before deciding how to proceed. Asami or Ben, do you have any concerns with that course of action?
Hello API Owners,
I’d like to ask API owners’ opinions with the current result of UseCounters.
WorkerControlledByServiceWorkerOutOfScope is about 1.03%
WorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope is about 0.56%
This feature changes Service Worker scope matching for Dedicated Workers so some dedicated workers might be controlled (not be controlled) although they used not to be controlled (used to be controlled).
The first UseCounter, WorkerControlledByServiceWorkerOutOfScope, counts the number of dedicated workers that will not be controlled by a service worker after this feature. It’s not equal to the number of possible broken sites unless dedicated workers send a HTTP request and the request is intercepted by a service worker. So this result is a maximum possible effect.
The second UseCounter, WorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope, counts the number of dedicated workers that will not be controlled by a service worker with a fetch event handler. It’s not equal to the number of possible broken sites because it includes an empty fetch event handler which does nothing. So this result is still an upper bound.
Note: In theory, there may be cases where the behavior of DW + SW with no/empty fetch handler changes due to the other functions in SW (e.g. install, activation events...)
I tried to refine the second UseCounter to exclude the sites with an empty fetch event handler but the implementation will be complicated. I’d like to avoid implementing another UseCounter if it’s not necessary.
Those numbers are high and if they had represented broken sites it would of course not work, so next step is to dig deeper into what those numbers represent and what the effect will be for individual sites.
A common method is to locate a sample set of sites that trigger
the use counter and check them out individually to get an idea
whether 1% or 90% of affected sites will break. (UKM; HTTP
Archive; GitHub; ...)
Another method is to make the counters better at detecting sites that will break (as you mentioned) and see if those end up at an acceptable level, but as you know, there is a lot of latency in that method.
I don't think there is a third method. Even "common sense" "it is all noise" requires someone to take a look at real sites to confirm it.
/Daniel
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALzRO2TXbtJufcCfitY5%3DXa9xhcLgAkfzyC-01ea6HPh7x6v3A%40mail.gmail.com.
Those numbers are high and if they had represented broken sites it would of course not work, so next step is to dig deeper into what those numbers represent and what the effect will be for individual sites.
A common method is to locate a sample set of sites that trigger the use counter and check them out individually to get an idea whether 1% or 90% of affected sites will break. (UKM; HTTP Archive; GitHub; ...)
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/653b75ae-d5b6-da7e-5335-4b77f7b41473%40gmail.com.
2021年4月23日(金) 17:13 Daniel Bratell <brat...@gmail.com>:
Those numbers are high and if they had represented broken sites it would of course not work, so next step is to dig deeper into what those numbers represent and what the effect will be for individual sites.
A common method is to locate a sample set of sites that trigger the use counter and check them out individually to get an idea whether 1% or 90% of affected sites will break. (UKM; HTTP Archive; GitHub; ...)
Thanks Daniel.
chromestatus has a section for the "top URLs that use the feature" based on HTTP Archive but it looks not yet populated for these counters:
Do we need to do work on our end to add support or does it just take time to populate?
For the feature to be logged it requires a service worker to be registered already from a previous, so if HTTP Archive only tests the first load it might not catch the sites that use the feature. I wonder if that's happening here.
I don't really knows how that feature works. I know Philip J has helped with analysing sites before so maybe he knows more ?
/Daniel2021年4月23日(金) 17:13 Daniel Bratell <brat...@gmail.com>:Those numbers are high and if they had represented broken sites it would of course not work, so next step is to dig deeper into what those numbers represent and what the effect will be for individual sites.
A common method is to locate a sample set of sites that trigger the use counter and check them out individually to get an idea whether 1% or 90% of affected sites will break. (UKM; HTTP Archive; GitHub; ...)
Thanks Daniel.chromestatus has a section for the "top URLs that use the feature" based on HTTP Archive but it looks not yet populated for these counters:Do we need to do work on our end to add support or does it just take time to populate?For the feature to be logged it requires a service worker to be registered already from a previous, so if HTTP Archive only tests the first load it might not catch the sites that use the feature. I wonder if that's happening here.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CA%2BvVX0hXrgKy1BZ4E1u%2BQe1xZ8%3DG5AqAzRwNwj29mOR-dYJkNQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw-JCQ107cY4jh0qRQt7t4_4Ra39KH%2BtS9GPZN88Tv8ucA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALzRO2TXbtJufcCfitY5%3DXa9xhcLgAkfzyC-01ea6HPh7x6v3A%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CA%2BvVX0hXrgKy1BZ4E1u%2BQe1xZ8%3DG5AqAzRwNwj29mOR-dYJkNQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw-JCQ107cY4jh0qRQt7t4_4Ra39KH%2BtS9GPZN88Tv8ucA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALzRO2TXbtJufcCfitY5%3DXa9xhcLgAkfzyC-01ea6HPh7x6v3A%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/653b75ae-d5b6-da7e-5335-4b77f7b41473%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/532aeeaa-891e-4caa-a09d-4dddcc18e7a3n%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALzRO2Smft8euHv0e50ENNNW3SOPc8k6f2PwSVujRbn-bME%3Dww%40mail.gmail.com.
The previous use counter also suggested the 10 highest population websites that record the use counter and I analyzed each of them. I confirmed that some of them are using a blob URL worker and the sites do not break.
(note for analysis) https://docs.google.com/document/d/11VHfAu3bhlSFVNQrpgHFUHylp2KbUnkyeGHvDRds5Sk/edit?usp=sharing
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALzRO2SnM8n3mQp7UWzq%2BYR28F4PRd6%2BSOFDatLkkjtf-dAsQA%40mail.gmail.com.
Hi Asami, a question below.On Wed, Jun 30, 2021 at 3:56 AM Asami Doi <asam...@chromium.org> wrote:
The previous use counter also suggested the 10 highest population websites that record the use counter and I analyzed each of them. I confirmed that some of them are using a blob URL worker and the sites do not break.
(note for analysis) https://docs.google.com/document/d/11VHfAu3bhlSFVNQrpgHFUHylp2KbUnkyeGHvDRds5Sk/edit?usp=sharingAre you saying that the top 10 highest population sites affected by this Intent will not be broken? If so, that's a very good sign.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAK7rkMj6Fq0MxLMof6EuVHikXa362aoLdkgURAHiP5A7bdcUAA%40mail.gmail.com.
Hi,The API owners met today and discussed this intent. Our current understanding is that the new use counter measures an upper bound on possibly-broken sites, as blob URLs are not broken as I understand it.
Thanks for discussing this. For full transparency, Asami and I wanted to explain a subtlety of the upper bound.
Summary: it's not a strict upper bound but it can be treated as one.
We started with the UseCounter called WorkerControlledByServiceWorkerOutOfScope. This measures the case where both of the following are true:
before this feature, a dedicated worker (DW) is controlled by a service worker (SW)
after this feature, DW is not controlled by SW.
This is a strict upper bound, and was roughly 1.38%.
But we realized that the only risk is for service workers that try to intercept requests, so we refined the use counter to WorkerControlledByServiceWorkerWithFetchEventHandlerOutOfScope. This measures the case where:
the same cases as WorkerControlledByServiceWorkerOutOfScope are true, and
SW has a FetchEvent handler.
This is still a strict upper bound, and was roughly 0.799%.
We later found that some sites are intentionally wanting the DW to be controlled by another service worker, SW2, when the feature is enabled. So we refined the use counter to exclude these cases with ControlledWorkerWillBeUncontrolled, which measures the case where:
before this feature, a DW is controlled by service worker SW
SW has a FetchEvent handler
after this feature, DW is not controlled by any service worker
This is no longer strictly an upper bound because the other SW2 might not be intended, but at roughly 0.798% the delta from the previous one was negligible. Therefore we believe this can still be considered an upper bound.
We later realized that blob URL workers are not affected by the change, so we refined the use counter to exclude these cases with ControlledNonBlobUrlWorkerWillBeUncontrolled (0.003%):