Closed
Bug 1226441
Opened 10 years ago
Closed 10 years ago
Service Worker functional events should wait for activate to complete
Categories
(Core :: DOM: Service Workers, defect)
Core
DOM: Service Workers
Tracking
()
RESOLVED
FIXED
mozilla45
People
(Reporter: catalinb, Assigned: bkelly)
References
Details
Attachments
(2 files)
|
5.15 KB,
patch
|
catalinb
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
|
8.70 KB,
patch
|
catalinb
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
In gecko, activate jobs are not synchronized with a queue as described in the spec. This means we can have racing activating service workers. This is not a problem at the moment since we don't wait for the worker to finish activating in Handle Fetch either, but it might be worth investigating later on.
| Assignee | ||
Comment 1•10 years ago
|
||
By coincidence bdahl noticed this makes things racey for web developers. For example, they should be able to count on the .ready promise resolving before the navigation-triggered updatefound event. But they can't because we don't wait for the activated state.
Catalin, how much work would this be? I think it would be worth uplifting to 44, although I wouldn't block the release on it.
Flags: needinfo?(catalin.badea392)
| Assignee | ||
Comment 2•10 years ago
|
||
Another reason to wait on the activate event is that this event is often used for upgrading IDB schemas. For example, see Jake's answer here:
http://stackoverflow.com/questions/29206836/accessing-indexeddb-in-serviceworker-race-condition
| Assignee | ||
Comment 3•10 years ago
|
||
We should talk about this in our next triage. I'm worried about production sites breaking because their fetch events fire before their IDB is updated in the activate event.
| Assignee | ||
Comment 4•10 years ago
|
||
I'm going to see what we can do for this today.
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Flags: needinfo?(catalin.badea392)
| Assignee | ||
Comment 5•10 years ago
|
||
A couple spec issues I saw related to this:
https://github.com/slightlyoff/ServiceWorker/issues/785
https://github.com/slightlyoff/ServiceWorker/issues/786
| Assignee | ||
Comment 6•10 years ago
|
||
Here is a wpt test that demonstrates the problem.
| Assignee | ||
Updated•10 years ago
|
Summary: Service Workers don't use an activation queue → Service Worker functional events should wait for activate to complete
| Assignee | ||
Comment 7•10 years ago
|
||
This implements the waiting behavior for both fetch and push events. It depends on the patches in bug 1189659.
Note, I explicitly don't do anything for activation queueing here. I split that off into bug 1226749. I expect that will be somewhat more rare, requiring two windows and a skipWaiting() service worker.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e4d9eb3cae9d
Attachment #8690275 -
Flags: review?(catalin.badea392)
| Assignee | ||
Comment 8•10 years ago
|
||
Comment on attachment 8690110 [details] [diff] [review]
P1 Add wpt test verifying fetch event waits for activate to complete.
Test passes with P2 patch.
Attachment #8690110 -
Flags: review?(catalin.badea392)
| Assignee | ||
Updated•10 years ago
|
Attachment #8690275 -
Attachment description: bug1226441_p2_waitforactivate.patch → P2 Delay functional event dispatch until service worker is activated. r=catalinb
| Assignee | ||
Updated•10 years ago
|
status-firefox43:
--- → wontfix
status-firefox44:
--- → affected
| Assignee | ||
Comment 9•10 years ago
|
||
Note, the M(4) errors are due to a race exposed by bug 1189659. There is a P4 patch there to fix the test, but I didn't include it in this try.
| Assignee | ||
Comment 10•10 years ago
|
||
Another try with that missing patch:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=3ed709abb2a0
| Assignee | ||
Comment 11•10 years ago
|
||
Also, note, the patches here follow the spec for waiting-for-activated whether or not we have a queue. The spec text in Handle Fetch does do anything with the queue at all. It just looks at the currently active worker regardless of any further activation queue logic.
| Reporter | ||
Updated•10 years ago
|
Attachment #8690110 -
Flags: review?(catalin.badea392) → review+
| Reporter | ||
Comment 12•10 years ago
|
||
Comment on attachment 8690275 [details] [diff] [review]
P2 Delay functional event dispatch until service worker is activated. r=catalinb
Review of attachment 8690275 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm
::: dom/workers/ServiceWorkerManager.cpp
@@ +4594,5 @@
> #endif
> + // Flush any pending functional events to the worker when it transitions to the
> + // activated state.
> + // TODO: Do we care that these events will race with the propagation of the
> + // state change?
I don't think so, but we should probably ask the spec folks.
Attachment #8690275 -
Flags: review?(catalin.badea392) → review+
Comment 13•10 years ago
|
||
Catalin, this needs to be uplifted, right? Do you mind asking for approval since you are more familiar with the changes, please?
Flags: needinfo?(catalin.badea392)
Comment 14•10 years ago
|
||
| Reporter | ||
Comment 15•10 years ago
|
||
Comment on attachment 8690110 [details] [diff] [review]
P1 Add wpt test verifying fetch event waits for activate to complete.
Approval Request Comment
(Uplift request for both patches)
[Feature/regressing bug #]: Service Workers
[User impact if declined]: These patches fix an important race condition related to how SW handle functional events.
[Describe test coverage new/current, TreeHerder]: web platform tests.
[Risks and why]: Minimal. Service Workers specific change.
[String/UUID change made/needed]: None
Flags: needinfo?(catalin.badea392)
Attachment #8690110 -
Flags: approval-mozilla-aurora?
Comment 16•10 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/d0823da696ba
https://hg.mozilla.org/mozilla-central/rev/671bc38157d2
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Comment 17•10 years ago
|
||
Comment on attachment 8690110 [details] [diff] [review]
P1 Add wpt test verifying fetch event waits for activate to complete.
test-only change, approved.
Attachment #8690110 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 18•10 years ago
|
||
Comment on attachment 8690275 [details] [diff] [review]
P2 Delay functional event dispatch until service worker is activated. r=catalinb
SW is planned for 44, taking it.
Attachment #8690275 -
Flags: approval-mozilla-aurora+
Comment 19•10 years ago
|
||
part2 failed to apply to aurora:
grafting 316548:671bc38157d2 "Bug 1226441 - Part 2: Delay functional event dispatch until service worker is activated; r=catalinb"
merging dom/workers/ServiceWorkerManager.cpp
merging dom/workers/ServiceWorkerManager.h
merging dom/workers/ServiceWorkerPrivate.cpp
merging dom/workers/ServiceWorkerPrivate.h
warning: conflicts while merging dom/workers/ServiceWorkerPrivate.h! (edit, then use 'hg resolve --mark')
can you take a look, thanks!
Flags: needinfo?(bkelly)
Updated•10 years ago
|
Flags: needinfo?(bkelly) → needinfo?(catalin.badea392)
| Reporter | ||
Comment 20•10 years ago
|
||
Landed the patches on aurora:
remote: https://hg.mozilla.org/releases/mozilla-aurora/rev/bab785163ce4
remote: https://hg.mozilla.org/releases/mozilla-aurora/rev/7ea5152b8417
Flags: needinfo?(catalin.badea392)
Comment 21•10 years ago
|
||
| bugherder uplift | ||
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/bab785163ce4
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/7ea5152b8417
status-b2g-v2.5:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•