[ServiceWorker] ServiceWorker Longevity (#840)

WRT: - https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope

> Once successfully registered, a service worker can ***and will*** be terminated when idle to conserve memory and processor power. An active service worker is automatically restarted to respond to events, 

Can anyone please confirm that the Mozilla documentation is wrong, or at least out of date?

There is certainly nothing in the spec (I can see) that mandates the immediate culling of viable and reusable SWs as soon as the event queue is empty.

I can see no evidence of the wisdom of a strategy that seeks to conserve memory and processor power by enduring the performance hit of re-initializing a SW for almost *every* event. Surely a simple TTL parameter on the registration backed up by a browser options parameter could do the necessary?

Perhaps just leave the thing up on the understanding that the OS knows best and can terminate at will? (If memory footprint stats are a justification then see TTL)

I can understand the school of thought that once said SW events "will only ever be Message events and they only everyhappen will big intervals" but I think scope creep is inevitable with this amazing functionality and the number of event-types is already multiplying like rabbits.

Depending on the throttle options set on : -
serviceWorkerRegistration.travelManager.subscribe({opions. . .})

GPS readings could be coming through for every 10 meter delta.  Once the new Location has been XHRed and self.postMessaged the SW is still active and waiting for another event. Makes sense?

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/840

Received on Wednesday, 24 February 2016 03:37:48 UTC