linebender/druid · error
drawing area has no window
Error message
drawing area has no window
What it means
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.
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at druid-shell/src/backend/gtk/window.rs:865 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of linebender/druid@0f8b1195e4 (2026-09-10).
Data as JSON: /api/errors/068d282160965b44.
Report an issue: GitHub.
Appendix: source
Thrown at druid-shell/src/backend/gtk/window.rs:865
if surface.is_none() || cur_size != (width, height) {
cur_size = (width, height);
self.surface_size.set(cur_size);
if let Some(s) = surface.as_ref() {
s.finish();
}
*surface = None;
if let Some(w) = self.drawing_area.window() {
if self.is_transparent.get() {
*surface = w.create_similar_surface(cairo::Content::ColorAlpha, width, height);
} else {
*surface = w.create_similar_surface(cairo::Content::Color, width, height);
}
if surface.is_none() {
return Err(anyhow!("create_similar_surface failed"));
}
} else {
return Err(anyhow!("drawing area has no window"));
}
}
Ok(())
}
/// Queues a call to `prepare_paint` and `paint`, but without marking any region for
/// invalidation.
fn request_anim_frame(&self) {
if self.in_draw.get() {
self.request_animation.set(true);
} else {
self.drawing_area.queue_draw()
}
}
/// Invalidates a rectangle, given in display points.
fn invalidate_rect(&self, rect: Rect) {
if let Ok(mut region) = self.invalid.try_borrow_mut() {View on GitHub (pinned to 0f8b1195e4)