{"record":{"id":"84989628470bd363","repo":"linebender/druid","slug":"failed-to-update-cairo-surface-size-to","errorCode":null,"errorMessage":"Failed to update cairo surface size to {:?}: {}","messagePattern":"Failed to update cairo surface size to (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/x11/window.rs","lineNumber":740,"sourceCode":"        let new_size = {\n            if size != self.area.get().size_px() {\n                self.area.set(ScaledArea::from_px(size, scale));\n                true\n            } else {\n                false\n            }\n        };\n        if new_size {\n            borrow_mut!(self.buffers)?.set_size(\n                self.app.connection(),\n                self.id,\n                size.width as u16,\n                size.height as u16,\n            );\n            borrow_mut!(self.cairo_surface)?\n                .set_size(size.width as i32, size.height as i32)\n                .map_err(|status| {\n                    anyhow!(\n                        \"Failed to update cairo surface size to {:?}: {}\",\n                        size,\n                        status\n                    )\n                })?;\n            self.add_invalid_rect(size.to_dp(scale).to_rect())?;\n            self.with_handler(|h| h.size(size.to_dp(scale)));\n            self.with_handler(|h| h.scale(scale));\n        }\n        Ok(())\n    }\n\n    // Ensure that our cairo context is targeting the right drawable, allocating one if necessary.\n    fn update_cairo_surface(&self) -> Result<(), Error> {\n        let mut buffers = borrow_mut!(self.buffers)?;\n        let pixmap = if let Some(p) = buffers.idle_pixmaps.last() {\n            *p\n        } else {","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/x11/window.rs#L722-L758","documentation":"Error in size_changed (x11 window): cairo_surface.set_size returned a non-Success cairo Status after a configure-notify resize, so the cairo backing surface could not be resized to the new dimensions. It fires when the buffer pool was resized but the cairo XCB surface rejected the new size — typically invalid dimensions (zero/negative/huge) or an XCB error during the request.","triggerScenarios":"Thrown at druid-shell/src/backend/x11/window.rs:740 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the new width/height are positive and within limits before calling set_size","Recreate the cairo surface from scratch if set_size fails, instead of keeping a stale one","Log the returned cairo Status and retry on the next configure event"],"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"}