Closed
Bug 1136066
Opened 10 years ago
Closed 10 years ago
Service worker registration when already registered doesn't update the worker
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: albert, Assigned: nsm)
References
Details
Attachments
(1 file, 1 obsolete file)
|
2.21 KB,
patch
|
Details | Diff | Splinter Review |
Steps to reproduce:
* Run https://acperez.github.io/sw-replace-test/
* Register worker 1.
* Refresh and note that fetch is called.
* Register worker 2 (same scope).
* Check registrations (Get registrations button) and see that worker 2 is registered.
* Refresh
* fetch method of worker 1 is still being called
* If tab is closed and reopened, then method of worker 2 is called.
Expected results:
* Register worker 1.
* Refresh and note that fetch is called.
* Register worker 2 (same scope).
* Check registrations (Get registrations button) and see that worker 2 is registered.
* Refresh.
* fetch method of worker 2 is called.
Updated•10 years ago
|
Blocks: ServiceWorkers-v1
| Assignee | ||
Comment 1•10 years ago
|
||
This happens because when the page is refreshed, the 'new' document is being controlled before the older one stops being controlled, leading to the new activation not happening. I'm looking into when we can put calls to Maybe{Start,Stop}Controlling to get the correct ordering.
Assignee: nobody → nsm.nikhil
| Assignee | ||
Comment 2•10 years ago
|
||
Boris, I'd like to move stop controlling to unloading to fix this ordering and
also be inline with the spec
http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#on-client-unload-algorithm
which states "The user agent must run these steps, or their equivalent, when
a service worker client unloads by unloading, being killed, or terminating."
Attachment #8568578 -
Flags: review?(bzbarsky)
Comment 3•10 years ago
|
||
Comment on attachment 8568578 [details] [diff] [review]
Stop controlling a document as soon as it is unloaded
r-, add -p to your diff options and I'll look again.
Past that, the spec needs to define exactly what it means by "unloading". Does it mean the "unloading document visibility change steps", does it mean the "unloading document cleanup steps", something else? Which one it means, exactly, is probably observable.
Attachment #8568578 -
Flags: review?(bzbarsky) → review-
| Assignee | ||
Comment 4•10 years ago
|
||
Sorry, I don't usually use MQ but this time I had to and it doesn't seem to set the option.
Attachment #8568578 -
Attachment is obsolete: true
Attachment #8568585 -
Flags: review?(bzbarsky)
| Assignee | ||
Comment 5•10 years ago
|
||
| Assignee | ||
Comment 6•10 years ago
|
||
Comment on attachment 8568585 [details] [diff] [review]
Stop controlling a document as soon as it is unloaded.
I guess I'll drop review until it is clarified.
Attachment #8568585 -
Flags: review?(bzbarsky)
Comment 7•10 years ago
|
||
I think
[diff]
showfunc = true
will give you -p bits in mq.
Comment 8•10 years ago
|
||
This appears to be working as expected. Assuming a single tab, when you navigate/refresh, this happens:
1. Page A is in a loaded state
2. Refresh/navigate for Page B
3. Request made to Page B's url
4. If the response replaces Page A, unload A
If the response has a "Content-Disposition" header, A would not be unloaded. Because the request for B goes out before the unload of A, it goes via the currently active service worker.
self.skipWaiting() can also be used to avoid the wait.
This overlap in client lifetime is only really an issue during development & with single tabs. I'm wanting Chrome to add some kind of ServiceWorker refresh button to devtools that does this:
1. Check for ServiceWorker update
2. Install
3. skipWaiting()
4. Refresh controlled pages
| Assignee | ||
Comment 9•10 years ago
|
||
Based on what Jake says, Gecko does this correctly right now.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•