-
Notifications
You must be signed in to change notification settings - Fork 315
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 a SW client.id persists across Discards/Reloads of the same page? #1263
Comments
We don't do this for reloads, or navigations to the same URL, so I don't think we should do it in the discarding case. Unless I'm missing something, it becomes a new client in terms of the HTML & fetch specs, so I don't think we should tell developers a different story here. Can you post some of the use-cases for knowing a tab is a reload of a discarded tab? I'm sure we can find some answer. |
Our usecases:
If SW client ID is not suitable, we could potentially add a new ID on Window / Document -- but usecase#1 requires it to be exposed to SW also. |
Please define your use case in more detail. Would making the |
Yes for usecase#2 explicitly sending an ID with wasDiscarded would work, however if this is explicit then it doesn't really need to SW client ID and could be a random ID that we surface in onfreeze / pagevisibility and echo back in wasDiscarded. Having a unique ID for the tab would obviate this - and potentially also address needs of usecase#1&3. |
I have concerns about adding another identifier tied to the tab concept. It would need some definition around life cycle, etc. It would be confusing for developers since the difference between it and client ID might be subtle. Providing the last discarded client ID seems more palatable. |
In my use case - https://github.com/inexorabletash/web-locks/blob/master/README.md#management--debugging - I have no dependency either way on the id being re-used across a navigates/restores, as long as at any point in time (1) it is unique to an environment settings object/agent (i.e.. frame or worker) and (2) it matches the SW's client.id (so a SW could roughly correlate).
Sounds better to me as well. Note if we expose the ID to the page/worker (is that actively discussed anywhere, BTW?) this could be done in user-space via the history API. (I think this discussion is somewhat predicated on the History API's single value being seen as too restrictive. But if a page has access to the ID, it could push just that into the history, and then use it as part of a key into another storage mechanism before/after restore.) |
I don't think there is an issue for this. Probably discussed in the odd comment or two in various SW issues, though. I would be in favor of something like |
There is issue #955 for exposing the Clients API, but I guess that's different to exposing clientId (even with the Clients API you can't get your own ID easily). Implementation-wise for Chromium, assigning a new client ID for reload isn't really about a new connection to the SW thread. It's a new Document which translates to a new host in the browser process, which creates a new client ID. A tab can have multiple clients. Would you want to preserve client id/provide lastDiscardedClientId for all Documents in the reloaded/discarded tab? |
Surfacing "lastClientId" or "lastDiscardedClientId" sounds good to me. |
I think what @jakearchibald said was preserving the same client-id across reloads wouldn't match the existing behavior in terms of the lifecycle of global objects/environments.
This sounds interesting. Is the idea something like:
|
Yes that is exactly the intended usage for lifecycle discarded usecase |
Closing in favour of whatwg/html#3378 (comment). Please reopen if I'm way off. |
For a given Client, if the client was discarded in the background due to memory pressure, later restored. Should this client get a new id, or should it keep its original id.
I have tested the current behavior in Chrome, and it seems the Client is assigned a new id. I guess this is expected since the reload would establish a new connection to the SW, and hence get a new id.
But it seems that there might be some use cases where persisting the id across discard/restore can be helpful.
The text was updated successfully, but these errors were encountered: