Anyone looked into running MediaSource from Worker?
I wanted to see if anyone has looked into MediaSource in Workers and if that might be useful for hls.js.
The explainer states: "enabling Dedicated Web Workers to be able to create MediaSource objects and MediaSource objectURLs. They may then postMessage or otherwise communicate those objectURLs to the main thread for use in attaching to media elements. The direct manipulation of the MediaSource and ancillary objects like SourceBuffer is allowed only from the context that originally created the MediaSource object. This allows both: improved access to, and improved performance of the MSE API".
It's currently in origin trials in Chrome with interest from Firefox and Safari.. A demo repo is available at https://github.com/wolenetz/mse-in-workers-demo
Just to update this - it's now shipping in Chrome as of v108.
https://chromestatus.com/feature/5177263249162240
Hi guys! Do you planned to work on this feature anytime soon or not? It could be a very nice performance improvement. Thanks!
It's not on the road map https://github.com/video-dev/hls.js/discussions/5194
The first step would be to abstract the use of the media element from the components that coordinate and perform network requests. Ideally network requests would also be performed in the worker. That however also introduces challenges with other elements that operate on the main loop like xhrSetup.