-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should clients.claim() control reserved Clients? #1090
Comments
A corner case that I'm concerned about is when the reserved client's active service worker is handling the main resource fetch while a new active worker is claiming. (The reserved client is considered being controlled already.) If this reserved client is excluded from That said, I think reserved clients should be considered the same as other clients for |
I think that is a different case. The new SW will not move to active if there is a controlled Client. It can use As I understand it Its unclear to me what the intent is if the Client is controlled by a different service worker registration due to overlapping scopes. @jakearchibald, what did you intend there? |
|
Well, if the only way to call |
The "corner case" scenario that I brought in the OP is:
|
I'm saying this is the bug in that case, not the claim(). The Client should not be allowed to be controlled by a redundant worker. If skipWaiting() is called then the reserved Client must be controlled by the new worker. |
I think the reserved client's handle fetch steps and SW2's |
I mean that skipWaiting() must update the controller on the reserved Client. Either the reserved Client gets SW1 and then upgraded to SW2 on skipWaiting(), or it comes in a bit later and just gets SW2. Why do you think the skipWaiting() would not operate on the reserved Client? It should not depend on the URL of the Client, but simply replace the Clients controlled by SW1. That should be a known list. |
I found the point where we misunderstood each other.
To my understanding |
This used to be the case when Clients had an associated registration and it was assumed the active one was the controller. Even still, that should work for reserved clients. That's probably wrong, now, though. The spec at some point was changed such that the Client has a specific service worker: https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-active-service-worker The skipWaiting() algorithm now needs to go update all those values. Either way, though, its the same affect. Clients->Registration->Active or Clients->ServiceWorker where ServiceWorker is updated to equal Active. |
Here's a bit of history: #586. We separated
I changed this part of the spec. It's nothing but moving the active service worker internal slot from the previous concept of service worker client (an environment settings object) to environment because we needed to attach a controller before the actual environment settings object/global object/document are created.
We separated it out from |
I think even further back the controlled windows has ServiceWorkerRegistration objects associated. Gecko was written to match and I wrote a bug to switch to the same model used by the spec: https://bugzilla.mozilla.org/show_bug.cgi?id=1247055 But as comment 3 points out there, though, this is handled down in the Activate algorithm. Its now step 7.1 here: https://w3c.github.io/ServiceWorker/#activation-algorithm
I believe a controlled reserved client should count as "using registration" in step 7 here. |
Ah.. yes. The controlled clients are covered by skipWaiting()-Activate step7.1 as you pointed! Reserved clients should count. Please ignore the scenario that I was concerned about. Sorry for my confusion. That clarified, |
So my concern is I'm having a really hard time figuring out how to implement claiming reserved clients. I can't use scope matching reliably because we don't really have the creation URL yet. Also, the code calling claim() is probably running in another process, so trying to search all browser processes for in-flight network requests with a match reserved Client is quite hard (and racy). I would really like to just say claim() does not operate on reserved clients. In many ways this is similar to what we do today. Today if a navigation starts just after a claim(), the resulting client may end up controlled by another reservation or uncontrolled if loaded via hard-refresh, etc. |
I understand your concern. I'll figure out how to make this part of the spec more implementable next week. And also whatwg/html#2455 and whatwg/html#2456. |
F2F: |
We'll follow up on the necessary work for this decision in #1245 as V2. (V1 won't expose any state that represents reserved clients.) |
Should it be possible for clients.claim() to take control of a reserved Client? I think the answer is probably "no" since the Client won't have a creation URL until its execution ready. I just want to verify that everyone agrees, though.
The text was updated successfully, but these errors were encountered: