Giter Site home page Giter Site logo

Threading about webcodecs HOT 5 CLOSED

w3c avatar w3c commented on July 24, 2024
Threading

from webcodecs.

Comments (5)

padenot avatar padenot commented on July 24, 2024

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.

from webcodecs.

chrishtr avatar chrishtr commented on July 24, 2024

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?

from webcodecs.

chcunningham avatar chcunningham commented on July 24, 2024

The spec's processing model now makes the threading behavior explicit
https://wicg.github.io/web-codecs/#codec-processing-model

Control thread: where you make the encoder/decoder (be it in a window or worker)
Codec thread: where actual encoding/decoding is to occur. May actually be N threads, but may not be the control thread.

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?

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.

from webcodecs.

aboba avatar aboba commented on July 24, 2024

Some questions were raised about WebCodecs support for threading here.

from webcodecs.

chcunningham avatar chcunningham commented on July 24, 2024

Chromium's WebCodecs implementation will offload decoding to a separate thread. We probably want to specify this behavior.

This is now spelled out in the spec. https://w3c.github.io/webcodecs/#control-thread-and-codec-thread

Big apps ported from native or advanced users probably want a synchronous API...

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.

I'm not sure it makes sense to expose the WebCodecs API to the main thread at all.

This same question is under more active discussion in #211.

from webcodecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.