Closed Bug 1471706 Opened 6 years ago Closed 6 years ago

maintain a version list for service worker state changes

Categories

(Core :: DOM: Service Workers, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: bkelly, Assigned: bkelly)

References

Details

Attachments

(2 files)

In bug 1462772 I routed all service worker state changes through the registration to ensure that updates across multiple objects are coherent.  This was necessary because of what happens when a binding object is created in a multi-process model:

1. An inert descriptor of the registration or service worker is captured on the parent process.
2. The descriptor is sent to the child process.
3. The descriptor is used to create a binding object in the child process.
4. The binding object creates an actor to attach back to the parent process.

Any state changes that occur between (1) and (4) must be sent to the new binding object.

Now in bug 1462772 we simply jump straight to the last known state.  While this is good enough for child-process mode where the SWM is in the same thread/process, it is not adequate for IPC mode.

In IPC mode we can actually have multiple state changes occur between (1) and (4).  We need to play these back in order so that events fire correctly.  We cannot simply skip to the end.

This bug will address this problem by maintaining a version list of changes to the registration state.
Comment on attachment 8988307 [details] [diff] [review]
P1 Track each registration state change with a version number stored on the descriptor. r=mrbkap

See comment 0 for background.

This patch adds a version number for each state change that occurs for a registration.  The version is a monotonically increasing number across the entire process running the SWM.

A lot of this patch is boilerplate to store the version number in the descriptor objects.  We store the version in the ServiceWorkerDescriptor in addition to the registration descriptor so that we can continue to look up the registration from the ServiceWorker object.

The bits to create and set the version number are in ServiceWorkerRegistrationInfo.
Attachment #8988307 - Flags: review?(mrbkap)
Comment on attachment 8988308 [details] [diff] [review]
P2 Maintain a version list of ServiceWorkerRegistrationInfo state changes. r=mrbkap

This patch maintains a versioned list of changes to each registrattion.  The changes are aged out of the list after 30 seconds to avoid pathological behavior over long periods.  Since we only need this list to account for cross-process races over short periods this 30 seconds threshold should be more than enough.

When a listener attaches to the ServiceWorkerRegistrationInfo the provided version will be used to automatically replay any updates that were missed for that descriptor.
Attachment #8988308 - Flags: review?(mrbkap)
Blocks: 1471912
Attachment #8988307 - Flags: review?(mrbkap) → review+
Attachment #8988308 - Flags: review?(mrbkap) → review+
Priority: -- → P2
Pushed by bkelly@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/7b59a210a7da
P1 Track each registration state change with a version number stored on the descriptor. r=mrbkap
https://hg.mozilla.org/integration/mozilla-inbound/rev/472d5e14e6bb
P2 Maintain a version list of ServiceWorkerRegistrationInfo state changes. r=mrbkap
https://hg.mozilla.org/mozilla-central/rev/7b59a210a7da
https://hg.mozilla.org/mozilla-central/rev/472d5e14e6bb
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: