{"record":{"id":"f2718fb8be1d5211","repo":"rustdesk/rustdesk","slug":"failed-to-get-a-drawing-context","errorCode":null,"errorMessage":"Failed to get a drawing context","messagePattern":"Failed to get a drawing context","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/platform/windows.rs","lineNumber":369,"sourceCode":"        }\n        if bm.bmPlanes != 1 {\n            bail!(\"Unsupported multi-plane cursor\");\n        }\n        if bm.bmBitsPixel != 1 {\n            bail!(\"Unsupported cursor mask format\");\n        }\n        Ok(bm)\n    }\n}\n\nstruct DC(HDC);\n\nimpl DC {\n    fn new() -> ResultType<Self> {\n        unsafe {\n            let dc = GetDC(0 as _);\n            if dc.is_null() {\n                bail!(\"Failed to get a drawing context\");\n            }\n            Ok(Self(dc))\n        }\n    }\n}\n\nimpl Drop for DC {\n    fn drop(&mut self) {\n        unsafe {\n            if !self.0.is_null() {\n                ReleaseDC(0 as _, self.0);\n            }\n        }\n    }\n}\n\nstruct CompatibleDC(HDC);\n","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/rustdesk/rustdesk/blob/91c9fccbb0f7bfe5f11644d5fbdec9b23fa10540/src/platform/windows.rs#L351-L387","documentation":"GetDC(NULL) returned a NULL screen device context — the sentinel guard in DC::new. Without a screen DC none of the subsequent cursor drawing/bit-block-transfer operations can run; this essentially only happens under extreme GDI object exhaustion or a headless/broken session graphics stack.","triggerScenarios":"Thrown at src/platform/windows.rs:369 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after releasing GDI resources — the process or session has likely exhausted its GDI handle quota","Check for leaking GetDC/SelectObject calls in the process (GDI leaks eventually cause exactly this)","Ensure the session has an active display device (not a detached services-only session)"],"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"}