rustdesk/rustdesk · error
Failed to get a drawing context
Error message
Failed to get a drawing context
What it means
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.
Source
Thrown at src/platform/windows.rs:369
}
if bm.bmPlanes != 1 {
bail!("Unsupported multi-plane cursor");
}
if bm.bmBitsPixel != 1 {
bail!("Unsupported cursor mask format");
}
Ok(bm)
}
}
struct DC(HDC);
impl DC {
fn new() -> ResultType<Self> {
unsafe {
let dc = GetDC(0 as _);
if dc.is_null() {
bail!("Failed to get a drawing context");
}
Ok(Self(dc))
}
}
}
impl Drop for DC {
fn drop(&mut self) {
unsafe {
if !self.0.is_null() {
ReleaseDC(0 as _, self.0);
}
}
}
}
struct CompatibleDC(HDC);
View on GitHub (pinned to 91c9fccbb0)
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)
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/platform/windows.rs:369 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/f2718fb8be1d5211.
Report an issue: GitHub.