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

> Is this easier than opting particular events in/out of firing in multiple instances?

No, its not easier.  But I'm worried about the conceptual change we're trying to introduce here.

It seems the web platform typically exposes js runtimes or globals as a DOM object like Window or Worker.  Each DOM object instance unambiguously references a single js global.  For SharedWorker we may attach many DOM objects to the same global, but they each individually still reference a specific js runtime.

What we are proposing here is to create a DOM object, `ServiceWorker`, that references a pool of globals.  You send an event to this thing and you really don't know where its going to run.  This really breaks things like `postMessage()`.

If we could go back in time it might have been better to expose a `MessageChannel` for each ServiceWorker instead of `postMessage()` directly.  Then it would be easier to reason about how a pool of worker threads function here.

Now, we could just say "all postMessage() events go to a single thread instance".  But that doesn't really make it easier to understand whats going on for people using the API.  It just makes it look like a single global for some uses, when its really not.

If we did this by exposing different `ServiceWorker` DOM objects for each global spun up then it might be easier for people to reason about.  I have `ServiceWorker` A and B, which are both running version X.  They can both handle the same kind of events, but if I `postMessage()` them the message events will fire on different globals.

I think I'd like to hear more from the other browser vendors before spending more time on this right now.  Internally we have decided to proceed with our "single SW thread across multiple processes" implementation for now.

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

Received on Tuesday, 9 August 2016 14:18:28 UTC