Re: [w3c/ServiceWorker] Consider exposing Page Lifecycle state to service-worker (#1345)

I commented the scenario below regarding a discussion on the Chromium bugtracker:

> My PWA has a notification click listener in its SW. When it is fired, it checks clients.matchAll (which, right now, seems to return clients even if they are frozen), sends a message to the first one it finds (using client.postMessage()) and then focuses it (client.focus()). If it doesn't find a client, it calls clients.openWindow().
> 
> Currently, the message gets stuck sometimes on Android and neither MessageChannel().port2.onmessage or -onmessageerror is ever fired. I suspect this is has to do with the tab/window being frozen.
> 
> My question/point is this: if clients.matchAll() would not return the frozen client(s), what would happen if I call clients.openWindow()? I would expect the SW to be able to open an existing client even if it's frozen. The user did leave it open, probably for a reason. Recycling the client makes sense?
> 
> In the case of a PWA it's probably less of a problem since I assume it would just use the existing application window and (re)load. But when it's a regular tab, clients.openWindow() would open a new tab even if there is an existing tab.

In short, it would help if I could determine if a client was frozen so the SW can at least act accordingly.

See https://bugs.chromium.org/p/chromium/issues/detail?id=957597#c11

-- 
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/1345#issuecomment-497208169

Received on Thursday, 30 May 2019 05:29:55 UTC