- From: Jake Archibald <notifications@github.com>
- Date: Wed, 16 Aug 2017 14:10:26 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/756/322900338@github.com>
Types of multi-instance use: * **For performance**: spin up n instances and distribute fetch events amongst them. Minor exploration doesn't show this to be a benefit. * **For isolation**: When the browser is closed, allow another process to run the service worker. But when the browser does open, run the service worker in there too. This seems to be what Edge/Safari are wanting it for. ## Option 1: No multiple instances. No change to the spec. Safari/Edge would have to find a way to work around this by switching from one worker to another, potentially serialising state to cater for use-cases like Facebook's. ## Option 2: Edge and Safari go ahead and use multiple instances, and we see what breaks. If only a few sites break, we could reach out to them. Facebook's case for instance could be fixed by passing message ports or using broadcast channel (https://github.com/w3c/ServiceWorker/issues/1185#issuecomment-322864908). If everything turns out fine, we only have to make a minor spec change to recognise there may be a pool of instances that can receive top-level events. If lots of sites break, but `postMessage` is the main cause, Edge/Safari could use tricks so `messageEvent.source.postMessage` tries to go back to the instance that sent the original message. That would certainly fix the Facebook case. If this works we could look at speccing it, but I'm not sure how. ## Option 3: Multiple instances becomes an opt-in feature, but Edge/Safari reject push subscriptions if it isn't enabled. ```js navigator.serviceWorker.register(url, { multiInstance: true }); ``` This is kinda messy, as we'd have to think of what happens if the registration is updated to opt-out after push subscriptions have been created. Also, it'll be tough for developers if they have to enable it for Edge/Safari, but disable it for Chrome/Firefox (because they don't support it). -- 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/756#issuecomment-322900338
Received on Wednesday, 16 August 2017 21:10:57 UTC