-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for web workers #43
Comments
The first question is whether WebCodecs should work in a worker at all. The current implementation in Chromium does not, as the existing media stack in Chromium assumes there is a frame. I hope to support dedicated workers in the future. There is a separate question about background and shared workers, which should be a separate issue. Options for getting data in and out:
|
Note that worker integration is discussed in the explainer under "Execution environment." Might be worth expanding that section to be a bit more concrete though. |
My main use case is to be able to do video manipulation on Currently I can |
@murillo128 In WEBRTC WG, we have discussed whether access to raw video is best provided by adding a method on the track, or on the sender/receiver (the approach currently taken by |
I'd like to add my voice to the requests for web worker support. We currently have a decode and render pipeline that happens entirely in a worker (using WebAssembly and an offscreen canvas). It'd be a real shame, and rather perverse, to have to shuffle samples to the main thread to get them decoded, then back to the worker to render them. |
This issue hasn't been updated in a while, but Chromium does plan on supporting WebCodecs in workers. In fact, Transferring |
Note that the support above is only for dedicated workers and that there are still open questions about shared workers and service workers. |
Having access to VideoDecoder from a dedicated worker is exactly what I need, so I'm happy! |
What about AudioDecoder? I notice that it outputs AudioBuffers, but these aren't exposed to Worker, nor are they transferable. |
The AudioDecoder support should have been added at the same time as VideoDecoder. It landed in 89.0.4332.2: It was merged back to 88.0.4324.29, so it should be available in Beta: I guess you are saying that underneath our worker-exposed AudioFrame lies the not-worker-exposed AudioBuffer, and therefore AudioWorker is not useable in workers? That is a bug, I've opened crbug.com/1160580. |
Is it possible to make
|
This is currently planned. The spec doesn't reflect it yet, but it's on the short list of things to add in Chromium. There's currently discussion on the WebAudio spec, which needs to be modified to expose AudioBuffer (tracking bug for Chromium). |
I think we can close this, but let me give a overview of where we landed. We now support all decoder/encoder interfaces in DedicatedWorker. I think WebAudio WG is near consensus to expose AudioBuffer to workers as well. VideoFrame and AudioFrame will be transferable. Spec work tracked in #129. To transfer frames from a MediaStream, the idea is to setup https://w3c.github.io/mediacapture-insertable-streams/#track-processor in the main window, but transfer it's Support for Service and Shared workers is not planned at this point. Feel free to re-open or file new sub issues if more to discuss. |
Are there any plans for sharedworker support or any way I can advocate on their behalf? The annoying scenario I end up with is a sharedworker spawning a dedicated worker... which I can probably deal with but it's less than ideal rn. |
Can you say more about your use case? The main reason we did not propose SharedWorker support is that the lifetime is undefined, and we were not aware of use cases that made sense in that context. In fact the use case of background encoding is still missing an appropriate worker type despite being on the original list of use cases. A secondary reason is that that postMessage() to/from a SharedWorker needs need to serialize the VideoFrames. We (Chrome implementors) did not implement serialization, as it is expensive and the paths are synchronous. |
How are webcodecs objects supposed to work with web workers? Should the mediastreamtrack be transferable from/to the main thread to/from a web worker?
The text was updated successfully, but these errors were encountered: