iced
iced copied to clipboard
Application freezes when hidden using wayland
Is there an existing issue for this?
- [X] I have searched the existing issues.
Is this issue related to iced?
- [X] My hardware is compatible and my graphics drivers are up-to-date.
What happened?
Under Hyprland (wayland), hidden windows are not drawn. This probably stalls the rendering and makes iced applications unusable as the applications update function is not called until the rendering finished. This happens with glow
and wgpu
. The provided log is from wgpu
after the window was hidden. As it can be seen, "Presented. End of Frame" does not appear at the end of the log when the window is hidden.
What is the expected behavior?
The applications stays usable because the update
function is still regularly called with new message.
Version
master
Operative System
Linux
Do you have any log output?
DEBUG wgpu_core::present > Presented. End of Frame
DEBUG wgpu_core::device > Buffer (161, 1, Vulkan) map state -> Waiting
DEBUG wgpu_core::device > Buffer (13, 1, Vulkan) map state -> Waiting
DEBUG wgpu_core::device > texture view (2, 291, Vulkan) is dropped
DEBUG wgpu_core::device > Create view for texture (1, 583, Vulkan) filters usages to COLOR_TARGET
DEBUG iced_wgpu::backend > Drawing
DEBUG wgpu_core::device > Buffer (159, 1, Vulkan) map state -> Idle
DEBUG wgpu_core::device > Buffer (156, 1, Vulkan) map state -> Idle
DEBUG wgpu_core::device::life > Texture view Valid((2, 291, Vulkan)) will be destroyed
DEBUG wgpu_core::device::life > Buffer Valid((161, 1, Vulkan)) map state -> Active
DEBUG wgpu_core::device::life > Buffer Valid((13, 1, Vulkan)) map state -> Active
DEBUG wgpu_core::present > Removing swapchain texture Valid((1, 583, Vulkan)) from the device tracker
Mesa's Wayland EGL implementation blocks on a frame
callback in eglSwapBuffers
if eglSwapInterval
is set to 1
(basically, if vsync is enabled). The Vulkan WSI implementation should be similar. The frame callback isn't sent to occluded windows.
See https://gitlab.freedesktop.org/mesa/mesa/-/issues/4932 for some discussion about software behavior this has impacted.
As I understand the best way to handle things would be to have drawing driven by the frame callback, rather than blocking on it: https://github.com/rust-windowing/winit/issues/2412
@ids1024 Do you happen to know if iced allows for overriding of renderer Settings?
I've checked the mpv repository and they say that they use eglSwapInterval 0
for openGL and present mode Mailbox
for vulkan. I've seen in iced_wgu that present_mode is set to AutoVSync
but I dont see any way of overriding this when launching my application with the run(Settings)
function provided by iced
It doesn't look like there's any setting to control this. Just disabling vsync isn't necessarily ideal either since you don't want a typical GUI application running with an uncapped frame-rate. Though that shouldn't be too much of a problem if it only redraws when the state within Iced changes.
Until this is fixed, you can work around this by forcing x11 even on wayland by setting the environment variable WINIT_UNIX_BACKEND
to x11
. This can by done in code with std::env::set_var("WINIT_UNIX_BACKEND", "x11");
(you should do that before you run your app with Application::run
).
Until this is fixed, you can work around this by forcing x11 even on wayland by setting the environment variable
WINIT_UNIX_BACKEND
tox11
. This can by done in code withstd::env::set_var("WINIT_UNIX_BACKEND", "x11");
(you should do that before you run your app withApplication::run
).
Unfortunately it seems not to work for me, atleast when window is on different workspace on Gnome 46