godot icon indicating copy to clipboard operation
godot copied to clipboard

Wayland: Pace frames by timing out

Open deralmas opened this issue 1 year ago • 0 comments

Fixes #87963.

This is a pretty popular approach that took a while for me to wrap my head around and which only recently got "official" support through an update, so I think that this is all-in-all a better option than the overkill 2000Hz ticking we have now :P

Basically, we wait for a frame event until a set time and then assume that we're occluded. There's also a new version of xdg-shell which directly reports us when a surface is suspended (it's not yet implemented in all compositors AFAICT), so that we don't have to go waiting around with a finnicky heuristic.

This solution isn't exactly perfect right now with the heuristic approach, as for a window to realize that it's occluded it has to stall for the whole timeout (and the reason I preferred the much overkill 2000 Hz :P ), but I think that we can set the timeout shorter if it's too long and it should be fine until the new protocol version becomes more common place.

Special thanks go to the guys over at #wayland on OFTC, who very patiently explained me this approach way too many times.


FTR, the current timeout is 1 second, but I think that we could go as low as 200ms without any big consequence. Further testing is needed.

Note that the new xdg-shell extension is not implemented in this PR, as I can't really test is as sway doesn't implement it yet.

deralmas avatar Jan 30 '24 18:01 deralmas