RustAudio / baseview

low-level window system interface for audio plugin UIs
Apache License 2.0
266 stars 57 forks source link

Add frame_interval_secs to WindowOpenOptions #47

Closed BillyDM closed 3 years ago

BillyDM commented 3 years ago

To achieve lower input latency in iced, I need the frame interval to run at 120fps. Iced sets the wgpu swapchain to Mailbox mode, so rendering still happens at 60fps. However, this causes less misses for the current frame reducing the perceived latency.

BillyDM commented 3 years ago

I also find that having the default as exactly 60fps feels smoother with less chugging than 15ms. This may be specific to the wgpu swapchain though, so let me know if it should stay 15ms.

wrl commented 3 years ago

It seems to me like the issue here is that Iced doesn't provide a mechanism for configuring the wgpu swapchain mode, and so in Mailbox mode the draw loop proceeds entirely unsynchronised relative to the vblank.

I'm going to reject this PR because I consider frame timing a window system issue and not one of the application itself. For example, Wayland surfaces receive frame/present requests for drawing their frame, so a Wayland baseview backend wouldn't have a timer at all. Likewise on macOS, we'll be investigating using CVDisplayLink instead of a timer.

X11 is a bit of an outlier in that it doesn't provide a reasonable mechanism for vblank notification for the purposes of timing or triggering frame drawing, and that's largely why we have a very simple timer for the time being. If your wgpu swapchain could be created in the Fifo mode, you would at the very least synchronise your draw loop to vblank (since presenting the drawn buffer blocks until vblank).

Still, this is something I am very interested in solving in the future, but since frame timing is dictated by the window system, you should consider the X11 frame timer a stopgap hack, and for that reason I'm unwilling to expose any part of it in the public API.