{"record":{"id":"1bffddd6db2c366c","repo":"linebender/druid","slug":"create-similar-surface-failed","errorCode":null,"errorMessage":"create_similar_surface failed","messagePattern":"create_similar_surface failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/gtk/window.rs","lineNumber":862,"sourceCode":"        let mut surface = self.surface.borrow_mut();\n        let mut cur_size = self.surface_size.get();\n        let (width, height) = (next_size(width), next_size(height));\n        if surface.is_none() || cur_size != (width, height) {\n            cur_size = (width, height);\n            self.surface_size.set(cur_size);\n            if let Some(s) = surface.as_ref() {\n                s.finish();\n            }\n            *surface = None;\n\n            if let Some(w) = self.drawing_area.window() {\n                if self.is_transparent.get() {\n                    *surface = w.create_similar_surface(cairo::Content::ColorAlpha, width, height);\n                } else {\n                    *surface = w.create_similar_surface(cairo::Content::Color, width, height);\n                }\n                if surface.is_none() {\n                    return Err(anyhow!(\"create_similar_surface failed\"));\n                }\n            } else {\n                return Err(anyhow!(\"drawing area has no window\"));\n            }\n        }\n        Ok(())\n    }\n\n    /// Queues a call to `prepare_paint` and `paint`, but without marking any region for\n    /// invalidation.\n    fn request_anim_frame(&self) {\n        if self.in_draw.get() {\n            self.request_animation.set(true);\n        } else {\n            self.drawing_area.queue_draw()\n        }\n    }\n","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/gtk/window.rs#L844-L880","documentation":"Error in resize_surface on GTK: w.create_similar_surface(cairo::Content::...) returned None, so a new cairo backing surface matching the drawing area's window could not be allocated at the requested size. It fires on window resize when cairo cannot create a similar surface for the given visual/size, typically due to resource exhaustion or an invalid window/visual.","triggerScenarios":"Thrown at druid-shell/src/backend/gtk/window.rs:862 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the surface creation with a smaller or current widget allocation","Verify drawing_area.window() is valid and realized before creating the surface","Recreate the surface on the next expose/configure event instead of failing hard"],"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"}