From 5e200913e440863ad1f323a5817c8cee03b5592c Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 6 Nov 2024 15:41:22 -0800 Subject: [PATCH] subsurface_widget: Clear subsurface list after calls to `::draw()` Otherwise the `draw` call in response to `AboutToWait` causes this list to grow, and eventually hit errors in `sendmsg` due to too many buffered file descriptors from creating subsurfaces. Probably the number of places `UserInterface::draw` are called should be cleaned up. And it shouldn't be called in `AboutToWiat` like this. Some improvements could probably be made in upstream iced. --- winit/src/platform_specific/mod.rs | 7 +++++++ winit/src/platform_specific/wayland/mod.rs | 4 ++++ winit/src/program.rs | 3 +++ 3 files changed, 14 insertions(+) diff --git a/winit/src/platform_specific/mod.rs b/winit/src/platform_specific/mod.rs index 5f1727620d..93e6f5f9ea 100644 --- a/winit/src/platform_specific/mod.rs +++ b/winit/src/platform_specific/mod.rs @@ -59,6 +59,13 @@ impl PlatformSpecific { } } + pub(crate) fn clear_subsurface_list(&mut self) { + #[cfg(all(feature = "wayland", target_os = "linux"))] + { + self.wayland.clear_subsurface_list(); + } + } + pub(crate) fn update_subsurfaces( &mut self, id: window::Id, diff --git a/winit/src/platform_specific/wayland/mod.rs b/winit/src/platform_specific/wayland/mod.rs index e4fcfd9d16..da080f7b04 100644 --- a/winit/src/platform_specific/wayland/mod.rs +++ b/winit/src/platform_specific/wayland/mod.rs @@ -181,6 +181,10 @@ impl WaylandSpecific { }; } + pub(crate) fn clear_subsurface_list(&mut self) { + let _ = crate::subsurface_widget::take_subsurfaces(); + } + pub(crate) fn update_subsurfaces( &mut self, id: window::Id, diff --git a/winit/src/program.rs b/winit/src/program.rs index 6d512c3d77..b6876aa900 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -963,6 +963,8 @@ async fn run_instance<'a, P, C>( }, Default::default(), ); + platform_specific_handler + .clear_subsurface_list(); let mut bytes = compositor.screenshot( &mut renderer, &mut surface, @@ -1713,6 +1715,7 @@ async fn run_instance<'a, P, C>( cursor, ) }; + platform_specific_handler.clear_subsurface_list(); if new_mouse_interaction != window.mouse_interaction { if let Some(interaction) =