emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.67k stars 1.56k forks source link

Ability to skip rendering a frame / ask for second pass #4976

Closed ficoos closed 2 days ago

ficoos commented 4 weeks ago

Is your feature request related to a problem? Please describe.

I would like to be able to specifically skip a frame because I know it will cause a graphical stutter due to sizing layouting. Being able to do ctx.skip_frame() or something similar to prompt the system to skip displaying the next frame and immediately request another repaint.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

emilk commented 2 weeks ago

I like this idea for covering up frame jitter issues, and have been considering it myself.

There's some trickyness to this to figure out:

ficoos commented 2 weeks ago

Avoiding an infinite loop is a non-issue IMHO because you can do any number of things to cause an infinite loop when programming. It is also difficult to detect if the skipping is due to the same cause or two different causes that happened to be in consecutive frames. There could maybe be a warning if it is called consecutively in debug by putting this information in a temp.

I think that the simplest thing would be to just skip painting and request a new frame. This makes the semantics almost identical to if the frame had been presented (the current behaviour) which would simplify the integration and backward compatibility.

The major issues with this that I see is actually that building this in to Widgets has a global effect (some operations can cause the UI to take twice as long to update) which some users may prefer jitter to lost frames.

This means it should probably be configurable whether to respect skip_frame requests.