{"record":{"id":"1005a43747f772de","repo":"linebender/druid","slug":"failed-to-create-cairo-surface","errorCode":null,"errorMessage":"Failed to create cairo surface: {}","messagePattern":"Failed to create cairo surface: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/x11/window.rs","lineNumber":212,"sourceCode":"            CairoXCBConnection::from_raw_none(\n                conn.get_raw_xcb_connection() as *mut cairo::ffi::xcb_connection_t\n            )\n        };\n        let cairo_drawable = XCBDrawable(window_id);\n        let mut xcb_visual = xcb_visualtype_t::from(*visual_type);\n        let cairo_visual_type = unsafe {\n            XCBVisualType::from_raw_none(\n                &mut xcb_visual as *mut xcb_visualtype_t as *mut cairo::ffi::xcb_visualtype_t,\n            )\n        };\n        let cairo_surface = XCBSurface::create(\n            &cairo_xcb_connection,\n            &cairo_drawable,\n            &cairo_visual_type,\n            self.size.width as i32,\n            self.size.height as i32,\n        )\n        .map_err(|status| anyhow!(\"Failed to create cairo surface: {}\", status))?;\n        Ok(cairo_surface)\n    }\n\n    // TODO(x11/menus): make menus if requested\n    pub fn build(self) -> Result<WindowHandle, Error> {\n        let conn = self.app.connection();\n        let screen_num = self.app.screen_num();\n        let id = conn.generate_id()?;\n        let setup = conn.setup();\n\n        let env_dpi = std::env::var(\"DRUID_X11_DPI\")\n            .ok()\n            .map(|x| x.parse::<f64>());\n\n        let scale = match env_dpi.or_else(|| self.app.rdb.get_value(\"Xft.dpi\", \"\").transpose()) {\n            Some(Ok(dpi)) => {\n                let scale = dpi / 96.;\n                Scale::new(scale, scale)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/x11/window.rs#L194-L230","documentation":"Error in create_cairo_surface (x11 window build path): XCBSurface::create failed to wrap the XCB window drawable in a cairo XCB surface, and the cairo Status is formatted into the message. It fires when the cairo/xcb connection, drawable, or visual type is invalid — e.g. unsupported visual, connection creation failure, or cairo rejecting the XCB setup — and is called from build.","triggerScenarios":"Thrown at druid-shell/src/backend/x11/window.rs:212 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the visual type obtained for the window is supported (24-bit/32-bit truecolor) before creating the surface","Check that the XCB connection was successfully converted to a cairo connection","Re-create the surface after the window/visual is fully initialized; log the cairo Status for the exact failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}