Skip to content

Commit

Permalink
subsurface_widget: Clear subsurface list after calls to ::draw()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ids1024 committed Nov 19, 2024
1 parent 1fef7e7 commit 5e20091
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions winit/src/platform_specific/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions winit/src/platform_specific/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) =
Expand Down

0 comments on commit 5e20091

Please sign in to comment.