{"record":{"id":"8ee2aa9d2f66d822","repo":"rustdesk/rustdesk","slug":"failed-to-get-display-the-displays-count-is","errorCode":null,"errorMessage":"Failed to get display {}, the displays' count is {}","messagePattern":"Failed to get display (.+?), the displays' count is (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/server/video_service.rs","lineNumber":324,"sourceCode":"                    Capturer::new(display).with_context(|| \"Failed to create capturer\")?,\n                ));\n            }\n        }\n    };\n}\n\n// This function works on privacy mode. Windows only for now.\npub fn test_create_capturer(\n    privacy_mode_id: i32,\n    display_idx: usize,\n    timeout_millis: u64,\n) -> String {\n    let test_begin = Instant::now();\n    loop {\n        let err = match Display::all() {\n            Ok(mut displays) => {\n                if displays.len() <= display_idx {\n                    anyhow!(\n                        \"Failed to get display {}, the displays' count is {}\",\n                        display_idx,\n                        displays.len()\n                    )\n                } else {\n                    let display = displays.remove(display_idx);\n                    match create_capturer(privacy_mode_id, display, display_idx, false) {\n                        Ok(_) => return \"\".to_owned(),\n                        Err(e) => e,\n                    }\n                }\n            }\n            Err(e) => e.into(),\n        };\n        if test_begin.elapsed().as_millis() >= timeout_millis as _ {\n            return err.to_string();\n        }\n        std::thread::sleep(Duration::from_millis(300));","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/src/server/video_service.rs#L306-L342","documentation":"In test_create_capturer's retry loop, Display::all() returned fewer displays than the requested display_idx. The requested monitor does not currently exist (index out of range — displays enumerated while being reconfigured, or the index refers to a disconnected monitor).","triggerScenarios":"Thrown at src/server/video_service.rs:324 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for display reconfiguration to settle — the loop retries until the timeout","Re-enumerate displays and pick a valid index (typically 0 for primary)","Verify the display index passed from the client matches the server's current monitor layout"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540","analyzedAt":"2026-09-10T19:53:44.083Z","contentChangedAt":"2026-09-10T19:53:44.083Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}