[ServiceWorker] consider allowing multiple worker thread instances for a single registration (#756)

Currently gecko (and maybe chrome?) has a bug where multiple service worker threads can be spun up for the same registration.  This can happen when windows in separate child processes open documents controlled by the same registration.  Per the spec, the FetchEvents should be dispatched to the same worker instance.  In practice, we spin up different work threads for each child process and dispatch there.

While discussing how to fix this, we started to wonder if its really a problem.  Service workers already discourage shared global state since the thread can be killed at any time.  If the service worker script is solely using Cache, IDB, etc to store state, then running multiple thread instances is not a problem.

It seems the main issue where this could cause problems is for code that wants to use global variables while holding the worker alive using waitUntil() or respondWith().  This is theoretically observable by script, but seems to have limited useful applications.

How would people feel about loosening the current spec to allow a browser to spin up more than one worker thread for a single registration?  When to execute multiple threads and how many would be up to the browser implementation.

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

Received on Wednesday, 30 September 2015 17:08:36 UTC