Frame presentation timing queries/control? #3634
Replies: 4 comments
|
This is something people have been interested in having on the Web for a long time. This is a very useful and well-referenced problem description; thank you! I think that most likely, this is a problem to be solved slightly-outside of WebGPU, in a way that would work for WebGL, 2d canvas, and other JS-driven animation as well. I've added this to our meeting agenda to surface some discussions. But realistically, unfortunately, there are a lot of other higher priority items for standardizers/implementers and I think it will be a while before we'll be able to deeply consider this. |
|
After researching this further, I also found a WIP experimental implementation effort in wgpu with more details on vendor APIs : gfx-rs/wgpu#2869 |
|
I want to make the suggestion that maybe this doesn't belong in webgpu and rather belongs in some other API? Think GL vs EGL or any of the other low-level starters like GLFW, etc... The reason is, at least for the web, there are many things contributing to the page, HTML, SVG, video, Canvas2D, WebGL, CSS animations, etc. A web dev would want to be able to synchronize all of them, not just a single canvas rendered to by WebGPU. Even if it was only WebGPU a single device can be used to render to mutiple canvases/surfaces. Separating the 2 would acknowledge that these are argaubly separate concerns. |
|
I filed an issue with the HTML spec for this: whatwg/html#8592 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
As far as I can tell (but maybe I didn't look hard enough), WebGPU does not currently provide a way to query the time at which previous video frames were presented to a screen, nor does it provide a way to check or control the time at which the frame currently being rendered should be presented to the screen, assuming that its rendering is completed in due time.
These features are useful in applications where minimal compute-to-display latency is desired, such as fast-paced interactive gaming or pro audio visualization. In this context, they can be used to slightly delay the rendering of a frame when the rendering time is known to be fairly reproducible and much smaller than the refresh rate, in order to make sure that the generated image will be presented to the screen as soon as possible after the underlying data has been collected.
These features are also useful when trying to avoid the jarring visual effect of fluctuations in said latency when rendering animated content (known as "jitter", "stutter" or "jank"). In this context, minimizing latency is not the primary goal, the main goal is rather to keep it as constant as possible in order to sync up with outgoing audio streams and to make sure that what is meant to be a constant-speed smooth animation on the application side does not become variable-speed irregular movement on the display side.
If you can confirm that this feature is not present in the existing WebGPU spec and would be of interest, we can discuss further what it should look like. For now, I'll just drop a bunch of links to reference material:
All reactions