This adds a new option, `extendedLifetime: true`, to the `SharedWorker` constructor. This requests that the shared worker be kept alive even after all current clients have unloaded. The primary use case is to allow pages to perform asynchronous work that requires JavaScript after a page unloads, without needing to rely on a service worker.
We intend to specify that the lifetime timeout for these shared workers be extended in the same way as service workers. Because the exact timeout of service workers is left implementation-defined, it's possible that code using this new feature could be non-interoperable. However, this has so far not proved to be a major problem in practice for service workers.
Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
None
None
No special support beyond DevTools' existing shared worker inspection support.
Shared workers are not yet supported on Android and Android WebView. However, we are concurrently working on enabling them there, and when we do, this feature will also be supported.
https://wpt.fyi/results/workers/tentative/SharedWorker-extendedLifetime.html
Origin trial desktop first | 139 |
Origin trial desktop last | 142 |
Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).
We are currently discussing some details in preparation for specification. The exact nature of how the lifetime extension works with regard to non-window clients, particularly, has only recently reached a tentative conclusion.