{"record":{"id":"2b2fb2f241b00a83","repo":"zed-industries/zed","slug":"failed-to-get-active-display-list-result-result","errorCode":null,"errorMessage":"Failed to get active display list. Result: {result}","messagePattern":"Failed to get active display list\\. Result: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/gpui_macos/src/display.rs","lineNumber":63,"sourceCode":"    }\n\n    /// Obtains an iterator over all currently active system displays.\n    pub fn all() -> impl Iterator<Item = Self> {\n        unsafe {\n            // We're assuming there aren't more than 32 displays connected to the system.\n            let mut displays = Vec::with_capacity(32);\n            let mut display_count = 0;\n            let result = CGGetActiveDisplayList(\n                displays.capacity() as u32,\n                displays.as_mut_ptr(),\n                &mut display_count,\n            );\n\n            if result == 0 {\n                displays.set_len(display_count as usize);\n                displays.into_iter().map(MacDisplay)\n            } else {\n                panic!(\"Failed to get active display list. Result: {result}\");\n            }\n        }\n    }\n}\n\n#[link(name = \"ApplicationServices\", kind = \"framework\")]\nunsafe extern \"C\" {\n    fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> CFUUIDRef;\n}\n\nimpl PlatformDisplay for MacDisplay {\n    fn id(&self) -> DisplayId {\n        DisplayId::new(self.0 as u64)\n    }\n\n    fn uuid(&self) -> Result<Uuid> {\n        let cfuuid = unsafe { CGDisplayCreateUUIDFromDisplayID(self.0 as CGDirectDisplayID) };\n        anyhow::ensure!(","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_macos/src/display.rs#L45-L81","documentation":"On macOS, GPUI enumerates connected monitors by calling the CoreGraphics function CGGetActiveDisplayList into a fixed 32-entry buffer. If CoreGraphics returns any non-zero CGError code, gpui_macos panics because it cannot build the display list the platform needs. The panic fires inside the API that lists displays, typically during application startup or while reacting to a screen reconfiguration.","triggerScenarios":"Calling gpui's display enumeration (the platform API backed by this code in crates/gpui_macos/src/display.rs, e.g. all_displays()) when CGGetActiveDisplayList returns a CGError: no WindowServer connection (headless SSH/CI session), a display reconfiguration in progress (plug/unplug, sleep/wake, GPU switching), or more active displays than the pre-allocated 32-slot buffer.","commonSituations":"Running a GPUI-based app over SSH or in CI on macOS where the WindowServer is unreachable; launching exactly while macOS switches GPUs or renegotiates displays after wake; kiosk or virtual-display setups with a very large display count.","solutions":["Run the app from a normal GUI login session (WindowServer reachable), not a bare SSH or CI shell on macOS","Retry launching after the display change settles: unplug/replug external monitors, or reboot to reset CoreGraphics state","If it repeats, reproduce with a tiny program calling CGGetActiveDisplayList and capture the returned CGError code, then report it upstream with that code","If you maintain gpui_macos, replace the panic with logging plus an empty iterator (or a Result) so callers can degrade gracefully"],"exampleFix":"// before (crates/gpui_macos/src/display.rs)\nif result == 0 {\n    displays.set_len(display_count as usize);\n    displays.into_iter().map(MacDisplay)\n} else {\n    panic!(\"Failed to get active display list. Result: {result}\");\n}\n\n// after: log and degrade instead of killing the process\nif result == 0 {\n    displays.set_len(display_count as usize);\n    displays.into_iter().map(MacDisplay)\n} else {\n    log::error!(\"CGGetActiveDisplayList failed with {result}; continuing with no displays\");\n    Vec::new().into_iter().map(MacDisplay)\n}","handlingStrategy":"validation","validationCode":"// probe CoreGraphics before initializing gpui on macOS\nuse core_graphics::display::CGDisplay;\n\nfn displays_available() -> bool {\n    CGDisplay::active_displays()\n        .map(|displays| !displays.is_empty())\n        .unwrap_or(false)\n}\n\nif !displays_available() {\n    eprintln!(\"no displays via CoreGraphics; run inside a GUI session\");\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":"// convert the startup panic into a diagnosable skip (CI/headless runs)\nlet boot = std::panic::catch_unwind(|| {\n    // gpui Application::new().run(...) path that lists displays\n});\nif boot.is_err() {\n    eprintln!(\"display initialization failed; aborting\");\n}","preventionTips":["Launch GPUI apps from a GUI login session, never a bare SSH shell on macOS","Wrap application bootstrap in catch_unwind in CI so display panics become skipped runs, not red herring crashes","Avoid launching during display reconfiguration (wake from sleep, docking); retry after a short delay"],"tags":["macos","gpui","coregraphics","display","panic"],"backgroundTag":"display-enumeration-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}