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

Sorry If I am out of context and late, but just leaving some feedback related to:

https://jakearchibald.com/2016/service-worker-meeting-notes/

    Are you maintaining global state within the service worker?
    Would this change break your stuff?
    If so, could you use a more persistent storage like shared workers / IndexedDB instead?

We have an app where we show some user generated HTML content (including JS/CSS, etc) in an iframe and the resource references inside that HTML are not present on any server but are available via a web worker running on a different origin.
So, we were using Service Worker to intercept the resource requests and fulfill them from the worker. Our implementation was to first have a handshake kind of thing in which the service worker is given one end of a `MessageChannel` and the worker is given the other and they communicate with each other via the `MessagePorts`.
Now, for this we have to maintain the service worker end of the port in the `ServiceWorkerGlobalScope`, so if is unreliable we have a problem with this change as we will loose the communication channel with the worker due to this. It does not seem to be possible to store this port in indexedDB as well
One interesting thing is to be able to use shared workers inside service worker, and then instead have the shared worker communicate with the other web worker and pass the content back to the service worker. So that may help. 


-- 
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-266081084

Received on Friday, 9 December 2016 18:09:13 UTC