rust-windowing/glutin

swap_buffers hangs when winit window is out of focus

zrezke opened this issue · 4 comments

zrezke commented

I have an egui application that uses eframe, which uses winit and glutin on native.

When clicking somewhere and loosing focus of the app (when the app is not visible anywhere), glutin hangs on swap_buffers.
See GIF in emilk/egui#2944
Line of code that hangs:
https://github.com/rust-windowing/glutin/blob/8e0960d7aa8c67ee709897001def551fc1d868bb/glutin/src/surface.rs#LL310C17-L310C17

Are you on Wayland? If you're using vsync it's expected behavior and can't be fixed other than not using vsync.

zrezke commented

Yes, I am on wayland + using vsync. Thanks for clarifying that it's expected behaviour!

I'll close it as 'not a bug', because glutin can't do anything about it, the issue is within the mesa, which is not really an issue, because it's due to compositor optimization of not sending frames to you when the window is invisible.

You might be interested in rust-windowing/winit#2412 which should help throttling events on Wayland in a way it should(alacritty for example is doing so for years to avoid freezing on Wayland, but it has internal infra).

zrezke commented

I'll close it as 'not a bug', because glutin can't do anything about it, the issue is within the mesa, which is not really an issue, because it's due to compositor optimization of not sending frames to you when the window is invisible.

You might be interested in rust-windowing/winit#2412 which should help throttling events on Wayland in a way it should(alacritty for example is doing so for years to avoid freezing on Wayland, but it has internal infra).

Thanks!