Re: [w3c/ServiceWorker] Clarification on what happens during a terminated activation (#1372)

This was discussed in issue 447 and issue 776. The design decision (although the justification appears missing from those issues) was that "fail to activate" could never happen.

I'm curious how you saw the behavior in Chrome. Chrome's intent is to implement that decision. In most cases, Chrome will not re-run the activate event handler.

BUT. We did run into one problem. During browser shutdown, Chrome closes each tab one-by-one in quick succession. We were seeing activation get triggered right at shutdown, and of course not finishing. The end result was a large % of service workers were activated who never properly finished their activate event handler, which seemed quite unfortunate.

Our hacky solution (since we don't know whether we're in shutdown or not at the layer we trigger activation in) was to delay activation by about 1 sec if it's triggered due to tab close. Then we try to activate. I think we also added an condition that if activation failed due to shutdown (we can sometimes detect it at that point), that the activation attempt is forgotten and it'd run it on the next worker startup.

The better solution is probably to detect shutdown before trying to activate, but we haven't done that.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1372#issuecomment-444719783

Received on Thursday, 6 December 2018 01:55:55 UTC