linebender/druid · error

Failed to update cairo surface size to

Error message

Failed to update cairo surface size to {:?}: {}

What it means

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.

Solutions

  1. Validate the new width/height are positive and within limits before calling set_size
  2. Recreate the cairo surface from scratch if set_size fails, instead of keeping a stale one
  3. Log the returned cairo Status and retry on the next configure event
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at druid-shell/src/backend/x11/window.rs:740 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/84989628470bd363. Report an issue: GitHub.

Appendix: source

Thrown at druid-shell/src/backend/x11/window.rs:740

        let new_size = {
            if size != self.area.get().size_px() {
                self.area.set(ScaledArea::from_px(size, scale));
                true
            } else {
                false
            }
        };
        if new_size {
            borrow_mut!(self.buffers)?.set_size(
                self.app.connection(),
                self.id,
                size.width as u16,
                size.height as u16,
            );
            borrow_mut!(self.cairo_surface)?
                .set_size(size.width as i32, size.height as i32)
                .map_err(|status| {
                    anyhow!(
                        "Failed to update cairo surface size to {:?}: {}",
                        size,
                        status
                    )
                })?;
            self.add_invalid_rect(size.to_dp(scale).to_rect())?;
            self.with_handler(|h| h.size(size.to_dp(scale)));
            self.with_handler(|h| h.scale(scale));
        }
        Ok(())
    }

    // Ensure that our cairo context is targeting the right drawable, allocating one if necessary.
    fn update_cairo_surface(&self) -> Result<(), Error> {
        let mut buffers = borrow_mut!(self.buffers)?;
        let pixmap = if let Some(p) = buffers.idle_pixmaps.last() {
            *p
        } else {

View on GitHub (pinned to 0f8b1195e4)