Comment by pjmlp

Comment by pjmlp 5 hours ago

4 replies

To be fair neither are WebGL and WebGPU, versus the native API counterparts, the best you can get are shadertoy demos, and product visualisation on ecommerce sites.

Due to tooling, sandboxing and not having any control about what GPU gets selected, or why the browser blakckboxes it and switches into software rendering.

samiv an hour ago

Not to mention

  - the incredible overhead of each and every API call
  - the nerfed timers that jitter on purpose
  - the limitation of a single rendering context and that you *must* use the JS main thread to all those rendering calls (so no background async for you..)
  • flohofwoe an hour ago

    > - the incredible overhead of each and every API call

    The calling overhead between WASM and JS is pretty much negligible since at least 2018:

    https://hacks.mozilla.org/2018/10/calls-between-javascript-a...

    > - - the nerfed timers that jitter on purpose

    At least Chrome and Firefox have "high-enough" resolution timers in cross-origin-isolated contexts:

    https://developer.chrome.com/blog/cross-origin-isolated-hr-t...

    ...also, if you just need a non-jittery frame time, computing the average over multiple frames actually gives you a frame duration that's stable and exact (e.g. 16.667 or 8.333 milliseconds despite the low-resolution inputs).

    Also, surpise: there are no non-jittery time sources on native platforms either (for measuring frame duration at least) - you also need to run a noise-removal filter over the measured frame duration in native games. Even the 'exact' presentation timestamps from DXGI or MTLDrawable have very significant (up to millisecond) jitter.

    > - the limitation of a single rendering context and that you must use the JS main thread to all those rendering calls (so no background async for you..)

    OffscreenCanvas allows to perform rendering in a worker thread: https://web.dev/articles/offscreen-canvas