service workers should control clients, not documents

RESOLVED DUPLICATE of bug 1425975

Status

()

defect
RESOLVED DUPLICATE of bug 1425975
3 years ago
a year ago

People

(Reporter: bkelly, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Currently we mark documents as being controlled.  This is not quite right in a number of ways.  As has been noted in other bugs we need to be able to control workers, etc.  But it also has subtle lifecycle issues.

Consider:

  addEventListener('fetch', function(evt) {
    evt.waitUntil(self.registration.unregister());
  });

This unregisters the service worker on the first fetch event.  If this is for the first navigation to the scope, then there are no controlled documents.  This means our current algorithm can kill the worker before we complete the fetch event handling due to the unregister running quickly.

In contrast, if we treated the window client as being controlled immediately before firing the fetch event as described in the spec, then this worker life cycle would be clear.  The worker would remain open until the client exits or stops being controlled.

Some of this is discussed in a closed spec issue I raised here:

  https://github.com/slightlyoff/ServiceWorker/issues/804
Assignee: nobody → dlee
Status: NEW → ASSIGNED
At the face-to-face meeting it was discussed that maybe clients really should be documents and not windows.  I would wait to do anything here.
Assignee: dlee → nobody
Status: ASSIGNED → NEW
(Reporter)

Updated

a year ago
No longer blocks: ServiceWorkers-compat
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1425975
You need to log in before you can comment on or make changes to this bug.