w3c / ServiceWorker

Service Workers
https://w3c.github.io/ServiceWorker/
Other
3.63k stars 315 forks source link

allow service workers to created nested dedicated workers #1529

Open wanderview opened 4 years ago

wanderview commented 4 years ago

I think we've discussed this before, but I cannot find the issue. It would be nice to allow service workers to created nested dedicated workers via new Worker(). This would allow the service worker to perform CPU intensive operations, like custom decoding, without potentially blocking the thread being used to process further FetchEvents.

https://github.com/chromeos/static-site-scaffold-modules/issues/40#issuecomment-673591331 is an example of where this would be useful.

jakearchibald commented 4 years ago

Yeah, I think workers are currently linked to a root document, so that needs to be changed to "document or service worker global", or something common between the two.

wanderview commented 4 years ago

I think dedicated workers can be nested under shared workers right now?

mfalken commented 4 years ago

Would the idea be that the dedicated worker lives as long as the service worker is running?

wanderview commented 4 years ago

Correct. Its lifetime would be bound by the lifetime of its parent, just like when creating a dedicated worker in a window or iframe.

tophf commented 3 years ago

FWIW, It would be useful for the new ManifestV3 browser extensions (currently implemented only in Chrome), which are built on service workers now so they've completely lost the ability to create workers in the background script.

Looks like https://github.com/whatwg/html/issues/411

cohenerickson commented 2 years ago

I would love to see this become implemented into the service worker spec, I think it would be beneficial for highly computational fetch requests.

ian97531 commented 2 years ago

I created a similar issue over in WHATWG: https://github.com/whatwg/html/issues/8362