iced-rs/iced · critical

Create window

Error message

Create window

What it means

iced's winit runtime panics when event_loop.create_window(window_attributes) fails during process_event's Resumed/window-setup handling. winit returns an error when the platform rejects window creation (invalid attributes, display server failure, resource limits); since the app cannot run without its main window, iced uses expect.

Solutions

  1. Inspect window()/Window::Settings values (size, position, icon) and fix out-of-range or invalid entries, especially if loaded from config.
  2. Verify the display connection is healthy and try a simpler settings set (no icon, default position) to isolate the failing attribute.
  3. Check system limits (ulimit -n for file descriptors) and sandbox/portal permissions.
  4. Update iced/winit - platform-specific create_window bugs are periodically fixed.

Example fix

// before
Window::Settings { position: Position::Specific(-99999.0, -99999.0), .. }
// after
Window::Settings { position: Position::Default, .. }
Defensive patterns

Strategy: validation

Validate before calling

// validate window settings loaded from config before passing to iced
fn valid(s: &iced::window::Settings) -> bool {
    s.size.0 > 0 && s.size.1 > 0 && s.size.0 < u32::MAX / 2 && s.size.1 < u32::MAX / 2
}

Prevention

When it happens

Trigger: Creating a window with unsupported/invalid WindowAttributes (bad icon, impossible position, incompatible settings), when the display connection is broken, or when the OS refuses a new window (resource exhaustion, sandbox restrictions).

Common situations: Corrupt or oversized window icon bytes; window_settings loaded from a config file with out-of-bounds position/size; Wayland compositor rejecting client-side decorations; running out of file descriptors; flatpak/sandbox missing portal permissions.

Related errors


AI-assisted analysis of iced-rs/iced@fa3bae5287 (2026-09-11). Data as JSON: /api/errors/71b4e58a15d69076. Report an issue: GitHub.

Appendix: source

Thrown at winit/src/lib.rs:337

                                    window_attributes.with_canvas(self.canvas.take())
                                };

                                log::info!(
                                    "Window attributes for id `{id:#?}`: {window_attributes:#?}"
                                );

                                // On macOS, the `position` in `WindowAttributes` represents the "inner"
                                // position of the window; while on other platforms it's the "outer" position.
                                // We fix the inconsistency on macOS by positioning the window after creation.
                                #[cfg(target_os = "macos")]
                                let mut window_attributes = window_attributes;

                                #[cfg(target_os = "macos")]
                                let position = window_attributes.position.take();

                                let window = event_loop
                                    .create_window(window_attributes)
                                    .expect("Create window");

                                #[cfg(target_os = "macos")]
                                if let Some(position) = position {
                                    window.set_outer_position(position);
                                }

                                #[cfg(target_arch = "wasm32")]
                                {
                                    use winit::platform::web::WindowExtWebSys;

                                    let canvas = window.canvas().expect("Get window canvas");

                                    let _ = canvas.set_attribute(
                                        "style",
                                        "display: block; width: 100%; height: 100%",
                                    );

                                    let window = web_sys::window().unwrap();

View on GitHub (pinned to fa3bae5287)