Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 1.2 KB

SW.md

File metadata and controls

25 lines (16 loc) · 1.2 KB

API to query Service Worker Client state

An explainer to define ability to query the Service Worker client lifecycle state.

Motivation

Service Workers do not have any information for determining if a client is frozen.

Two use cases exist:

  • A Service Worker may continuously postMessage to a client that is frozen. The message payloads will stack up, effectively leaking memory causing a premature discard of the client.
  • Being able to see frozen clients is desirable for ServiceWorkers that handle push notifications and preferentially invoke Client.focus() instead of using Clients.openWindow() to avoid tab proliferation.

Changes

Since the Service Worker specification does not depend on Page Lifecycle and not all browsers implement that specification patched changes are available.

Primarily a ClientLifecycleState was introduced to indicate the state of the client at the time the client was created. (ie. snapshot).