-
Notifications
You must be signed in to change notification settings - Fork 137
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
Threading #51
Comments
Both seem useful. Big apps ported from native or advanced users probably want a synchronous API and use their own threading synchronized via shared memory to keep caches hotter when doing something with the output afterwards. Other users probably want something a bit more ergonomic. Parallelism inside Web Codec constructs will be some sort of fork-and-join, but that's useful for intra-frame parallelism, for encoding video. |
I'm not sure it makes sense to expose the WebCodecs API to the main thread at all. Shouldn't it always be in a worklet or worker? Is there a compelling use case that requires the main thread? |
The spec's processing model now makes the threading behavior explicit Control thread: where you make the encoder/decoder (be it in a window or worker)
This question probably goes away with my comment above. Apps with lots of main thread activity and/or heavy UI (e.g. video conferencing) should still use WebCodecs in a worker to avoid contention with controlling the codec and painting their UI. But for other apps, Window is fine. |
Some questions were raised about WebCodecs support for threading here. |
This is now spelled out in the spec. https://w3c.github.io/webcodecs/#control-thread-and-codec-thread
We discussed this in the call w/ audio epxerts. It is true that many are coming from a synchronous API, but they concluded that this was not a requirement for them. We also discussed how our API's under the hood are often async and they stated that they did not desire for us to hide that from them at the JS layer. Please open a new issue for this if I've overlooked anything.
This same question is under more active discussion in #211. |
Chromium's WebCodecs implementation will offload decoding to a separate thread. We probably want to specify this behavior.
An alternative would be to specify a Worklet type for codec implementations, but this doesn't seem compatible with having a codec that uses many threads.
The text was updated successfully, but these errors were encountered: