{"record":{"id":"67e7bfe87cb9886a","repo":"linebender/druid","slug":"unable-to-create-surface","errorCode":null,"errorMessage":"unable to create surface","messagePattern":"unable to create surface","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"druid-shell/src/backend/wayland/surfaces/surface.rs","lineNumber":50,"sourceCode":"pub struct Surface {\n    pub(super) inner: std::sync::Arc<Data>,\n}\n\nimpl From<std::sync::Arc<Data>> for Surface {\n    fn from(d: std::sync::Arc<Data>) -> Self {\n        Self { inner: d }\n    }\n}\n\nimpl Surface {\n    pub fn new(\n        c: impl Into<CompositorHandle>,\n        handler: Box<dyn window::WinHandler>,\n        initial_size: kurbo::Size,\n    ) -> Self {\n        let compositor = CompositorHandle::new(c);\n        let wl_surface = match compositor.create_surface() {\n            None => panic!(\"unable to create surface\"),\n            Some(v) => v,\n        };\n\n        let current = std::sync::Arc::new(Data {\n            compositor: compositor.clone(),\n            wl_surface: RefCell::new(wl_surface),\n            outputs: RefCell::new(std::collections::HashSet::new()),\n            buffers: buffers::Buffers::new(compositor.shared_mem(), initial_size.into()),\n            logical_size: Cell::new(initial_size),\n            scale: Cell::new(1),\n            anim_frame_requested: Cell::new(false),\n            handler: RefCell::new(handler),\n            idle_queue: std::sync::Arc::new(std::sync::Mutex::new(vec![])),\n            active_text_input: Cell::new(None),\n            damaged_region: RefCell::new(Region::EMPTY),\n            deferred_tasks: RefCell::new(std::collections::VecDeque::new()),\n        });\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/wayland/surfaces/surface.rs#L32-L68","documentation":"Surface::new asks the compositor to allocate a new WlSurface; if the compositor returns None the library panics with this message. This indicates the Wayland compositor refused or failed to create the underlying protocol surface, so no window can be constructed.","triggerScenarios":"Calling Surface::new (public constructor) with a compositor whose create_surface() returns None — i.e. the compositor cannot allocate a new wl_surface at that moment.","commonSituations":"Connecting to a broken or half-initialized Wayland compositor, WAYLAND_DISPLAY / XDG_RUNTIME_DIR pointing at a stale socket, compositor resource exhaustion, or a custom/test compositor stub that always returns None from create_surface.","solutions":["Verify the Wayland environment is healthy: echo $WAYLAND_DISPLAY / $XDG_RUNTIME_DIR and confirm the socket exists before creating windows.","Test with a known-good compositor (e.g. weston, sway, GNOME Wayland) to rule out compositor-specific limitations.","Check that create_surface returning None is not a stub/test-double behavior in your environment.","Reconnect to the compositor (rebuild the handle) and retry surface creation if the compositor restarted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the Wayland environment before Surface::new\nfn wayland_env_ok() -> bool {\n    std::env::var(\"WAYLAND_DISPLAY\").is_ok()\n        && std::env::var(\"XDG_RUNTIME_DIR\")\n            .map(|d| std::path::Path::new(&d).exists())\n            .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"let surface = std::panic::catch_unwind(AssertUnwindSafe(|| {\n    Surface::new(&compositor, handler, size)\n}))\n.map_err(|_| anyhow::anyhow!(\"compositor failed to create surface\"))?;","preventionTips":["Check WAYLAND_DISPLAY and XDG_RUNTIME_DIR before launching","Fall back to X11 backend when the Wayland compositor is unavailable","Test against a real compositor, not stubs, before shipping","Log compositor connection health at startup"],"tags":["wayland","panic","surface-creation","compositor"],"backgroundTag":"resource-not-found","analyzedSha":"0f8b1195e4e073f9597f2865299c3d18f8e4005f","analyzedAt":"2026-09-10T14:27:34.582Z","contentChangedAt":"2026-09-10T14:27:34.582Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}