{"record":{"id":"1d6b97d200990c92","repo":"linebender/druid","slug":"failed-to-initialize-the-displays-event-loop","errorCode":null,"errorMessage":"failed to initialize the displays event loop!","messagePattern":"failed to initialize the displays event loop!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"druid-shell/src/backend/wayland/outputs/mod.rs","lineNumber":38,"sourceCode":") -> Result<calloop::channel::Channel<Event>, error::Error> {\n    tracing::debug!(\"detecting xdg outputs\");\n    match output::detect(env) {\n        Ok(rx) => return Ok(rx),\n        Err(cause) => tracing::info!(\"unable to detect xdg outputs {:?}\", cause),\n    }\n\n    Err(error::Error::string(\"unable to detect display outputs\"))\n}\n\npub(super) fn current() -> Result<Vec<Meta>, error::Error> {\n    let dispatcher = display::Dispatcher::default();\n    let rx = auto(&dispatcher)?;\n    let env = display::new(dispatcher)?;\n    let mut cache = std::collections::BTreeMap::new();\n    let mut eventloop: calloop::EventLoop<(\n        calloop::LoopSignal,\n        &mut std::collections::BTreeMap<String, Meta>,\n    )> = calloop::EventLoop::try_new().expect(\"failed to initialize the displays event loop!\");\n    let signal = eventloop.get_signal();\n    let handle = eventloop.handle();\n    handle\n        .insert_source(rx, {\n            move |event, _ignored, (signal, cache)| {\n                let event = match event {\n                    calloop::channel::Event::Msg(event) => event,\n                    calloop::channel::Event::Closed => return signal.stop(),\n                };\n\n                match event {\n                    Event::Located(meta) => {\n                        cache.insert(meta.name.clone(), meta);\n                    }\n                    Event::Removed(meta) => {\n                        cache.remove(&meta.name);\n                    }\n                }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/wayland/outputs/mod.rs#L20-L56","documentation":"The Wayland outputs/displays module builds a calloop event loop to track monitor (output) metadata changes, initializing a per-display BTreeMap cache. If calloop::EventLoop::try_new() fails while setting up this loop in current(), the code panics with expect and this message, aborting display-information initialization.","triggerScenarios":"calloop EventLoop::try_new() returning Err — epoll_create1 failure from exhausted file descriptors, sandboxed syscall filters (seccomp), or memory pressure — when current() is called to enumerate displays on Wayland.","commonSituations":"Apps launched under Flatpak/Snap with restrictive sandboxing; systems at the fd limit (many open windows/sockets or leaking fds); embedded Wayland environments; multi-monitor setups querying display metadata at startup.","solutions":["Raise the file-descriptor limit (`ulimit -n`) and audit for fd leaks in the process.","Adjust sandbox/seccomp profiles to allow epoll syscalls; test by running unsandboxed.","Free memory / check for OOM conditions at startup.","Patch or upgrade so failure falls back to a cached/empty display list instead of panicking.","Update druid-shell; newer revisions reworked wayland output handling."],"exampleFix":"// before\nlet mut eventloop = calloop::EventLoop::try_new()\n    .expect(\"failed to initialize the displays event loop!\");\n\n// after\nlet mut eventloop = calloop::EventLoop::try_new()\n    .map_err(|e| tracing::error!(\"displays event loop init failed: {e}\"))\n    .unwrap_or_default_fallback(); // degrade to polling display list once at startup","handlingStrategy":"try-catch","validationCode":"// preflight epoll availability before display enumeration\nlet epoll_ok = unsafe { libc::epoll_create1(0) } >= 0;\nif !epoll_ok { /* fall back to one-shot display query */ }","typeGuard":null,"tryCatchPattern":"match calloop::EventLoop::try_new() {\n    Ok(el) => run_display_loop(el),\n    Err(e) => {\n        log::error!(\"displays loop init failed: {e}\");\n        // fall back to a static snapshot of outputs\n    }\n}","preventionTips":["Check fd limits and sandbox syscall filters before launching on Wayland.","Verify display enumeration works when running outside Flatpak/Snap first.","Upgrade druid-shell for revised wayland output handling.","Watch for fd leaks via /proc/<pid>/fd growth in long sessions."],"tags":["wayland","linux","calloop","displays","panic","fd-exhaustion"],"backgroundTag":"module-init-failed","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"}