Re: [w3c/ServiceWorker] Using BroadcastChannel to wake up a service worker (#975)

We are using Server Sent Events to notify web clients that some server side action has been triggered on tasks they are interested in whilst they have the SPA open.

Typically a User is assigned to multiple projects and they tend to have multiple tabs open with various application screens (SPA). There maybe changes to those projects that happen elsewhere whilst they have the app open and we notify which projects changed and then carry out client side actions depending on the change. 

The active ServiceWorker part of this is very short lived, a message is received by the ServiceWorker it then notifies all attached WindowClients of the event and then it's done.  

We initially implemented this in the browser using a ServiceWorker which was easy to implement but we were hit by the issue of the SW going to sleep and not reawakening on an SSE event, we were unable to find any way to reliably keep the SW 'alive'.

We then switched these to SharedWorkers as we can keep them alive and that works but the issue here is they are not implemented on Chrome Android.

So whilst it may be fair to say anything you can do with waking up a ServiceWorker can be done with a SharedWorker already, SharedWorkers are not available everywhere and it's not just Safari that hasn't implemented them. 

So waking up a ServiceWorker on a MessageEvent would still be very useful.

-- 
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/975#issuecomment-977938968

Received on Wednesday, 24 November 2021 14:38:19 UTC