iced-rs/iced · error
Remove user interface
Error message
Remove user interface
What it means
Panic from `user_interfaces.remove(&id).expect("Remove user interface")` when handling a resize between redraws. Every registered window must have a user interface entry, so a missing entry indicates the window's UI was removed without unregistering the window — an internal invariant violation.
Source
Thrown at winit/src/lib.rs:761
continue;
};
let Some((id, mut window)) = window_manager.get_mut_alias(id) else {
continue;
};
let physical_size = window.state.physical_size();
let mut logical_size = window.state.logical_size();
if physical_size.width == 0 || physical_size.height == 0 {
continue;
}
// Window was resized between redraws
if window.surface_version != window.state.surface_version() {
window.renderer.hint(window.state.scale());
let ui = user_interfaces.remove(&id).expect("Remove user interface");
let layout_span = debug::layout(id);
let _ = user_interfaces
.insert(id, ui.relayout(logical_size, &mut window.renderer));
layout_span.finish();
current_compositor.configure_surface(
&mut window.surface,
physical_size.width,
physical_size.height,
);
window.surface_version = window.state.surface_version();
}
let redraw_event =
core::Event::Window(window::Event::RedrawRequested(Instant::now()));
View on GitHub (pinned to d146509d89)
Solutions
- Update iced — bookkeeping races between close and redraw have been fixed upstream
- Avoid closing windows from inside redraw-synchronous code paths
- If forking, guard the remove with `if let Some(ui)` instead of expect
Example fix
// before
let ui = user_interfaces.remove(&id).expect("Remove user interface");
// after
if let Some(ui) = user_interfaces.remove(&id) { ... } Defensive patterns
Strategy: type-guard
Validate before calling
// application-side: never call window close and rely on redraws for the same id in the same tick
Prevention
- Avoid closing windows synchronously from inside redraw-driven code
- Keep iced updated — close/redraw races are fixed upstream
- If forking, prefer `if let Some(ui)` over expect in interface registry access
When it happens
Trigger: A RedrawRequested arrives for a window whose user interface was already removed (e.g. window closed during redraw, or ui_caches/interfaces bookkeeping desynced after Close/SetExclusive actions racing the event loop).
Common situations: Rapid window close while a redraw is pending; custom window management via subscription/Action::Close racing redraw events; bugs in forked runtimes.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of iced-rs/iced@d146509d89 (2026-09-11).
Data as JSON: /api/errors/4aec537967be0da6.
Report an issue: GitHub.