{"record":{"id":"068d282160965b44","repo":"linebender/druid","slug":"drawing-area-has-no-window","errorCode":null,"errorMessage":"drawing area has no window","messagePattern":"drawing area has no window","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/gtk/window.rs","lineNumber":865,"sourceCode":"        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\n    /// Invalidates a rectangle, given in display points.\n    fn invalidate_rect(&self, rect: Rect) {\n        if let Ok(mut region) = self.invalid.try_borrow_mut() {","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/gtk/window.rs#L847-L883","documentation":"Error in resize_surface on GTK: self.drawing_area.window() returned None, so there is no GdkWindow to create the cairo similar surface against. It fires when the widget is not yet realized (no native window allocated) at the time a resize is processed, i.e. resize arrives before the drawing area is mapped.","triggerScenarios":"Thrown at druid-shell/src/backend/gtk/window.rs:865 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Defer surface creation until the widget's realize/map signal fires","Call realize()/allocate on the drawing area before resizing the surface","Skip the resize and recreate the surface on the next configure/expose when the window exists"],"exampleFix":null,"handlingStrategy":"fallback","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"}