-
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
consider firing a "clientcontrolled" event on ServiceWorkerGlobalScope #886
Comments
Pre F2F notes: Let's make sure we have all the use cases here. Do we need clientuncontrolled? Realise that's been avoided in the past with sharedworker. |
I think something like I'm not sure about worker clients, though. Those might still be based on GC. |
I'm not really convinced we understand the lifetime of a window well enough though. E.g., when you navigate the previous window can still be there in some form. Is there a clear enough action in HTML (that is implemented as such too) we can tie this too? |
Service worker control is tied to "active" documents and windows AFAICT. We are pretty consistent in wpt tests in expecting Whether we have the right text in the spec or not, I don't know. But it is happening today. |
It looks like document client-wise, 7.8.10 History Traversal's step 3
For "clientuncontrolled", it seems like unload a document is already linked in appropriately. Specifically, Handle Service Worker Client Unload's "unloading" link links to HTML's |
I suspect we want "fully active" documents, not just active. Still, there's a whole bunch of things around the lifecycle of documents that is not interoperable. |
F2F: |
Here are some other cases where a
Edit: Note, in Firefox 58 and earlier we did not change the client id on document.open() even though we replaced the global. We were incorrectly tying the client to the document. In Firefox 59 we start minting a new client id to reflect the new global. |
I'd like to tentatively propose that we fire a
clientcontrolled
event on the ServiceWorkerGlobalScope when that worker begins controlling a client. There could also be aclientuncontrolled
event, but that is less important to me at the moment.This could enable service workers to maintain and track state more specifically than they can do today. Right now SWs can infer which clients are going to be controlled from FetchEvent, but its really an approximation. Some documents will fail to load or be closed. Exposing these events would provide better tracking.
My real reason for suggesting this, though, is to handle a corner case with bfcache. I realize firefox might be the only browser to implement bfcache, so this may not be a strong argument. But consider the following situation:
Some options we considered, but currently don't like:
I'm open to suggestions, but the
clientcontrolled
event would have wider application and would let the SW behave sensibly to this case.The text was updated successfully, but these errors were encountered: