linebender/druid · error

unable to acquire underlying compositor to create a region

Error message

unable to acquire underlying compositor to create a region

What it means

Guard panic in Compositor for CompositorHandle::create_region: the Weak reference to the underlying compositor can no longer be upgraded because it was dropped. It fires when an opaque/input region must be created for a surface after the compositor backend has been torn down — a use-after-drop of wayland resources.

Solutions

  1. Keep the underlying compositor alive for the lifetime of any handle that can create regions
  2. Upgrade the Weak reference first and skip region creation gracefully if the compositor is gone
  3. Drop CompositorHandle when its compositor is dropped to prevent stale use
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at druid-shell/src/backend/wayland/surfaces/mod.rs:144 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/da599f884d967fee. Report an issue: GitHub.

Appendix: source

Thrown at druid-shell/src/backend/wayland/surfaces/mod.rs:144

impl Compositor for CompositorHandle {
    fn output(&self, id: u32) -> Option<outputs::Meta> {
        match self.inner.upgrade() {
            None => None,
            Some(c) => c.output(id),
        }
    }

    fn create_surface(&self) -> wlc::Main<WlSurface> {
        match self.inner.upgrade() {
            None => panic!("unable to acquire underlying compositor to create a surface"),
            Some(c) => c.create_surface(),
        }
    }

    fn create_region(&self) -> wlc::Main<WlRegion> {
        match self.inner.upgrade() {
            None => panic!("unable to acquire underlying compositor to create a region"),
            Some(c) => c.create_region(),
        }
    }

    fn shared_mem(&self) -> wlc::Main<WlShm> {
        match self.inner.upgrade() {
            None => panic!("unable to acquire underlying compositor to acquire shared memory"),
            Some(c) => c.shared_mem(),
        }
    }

    fn get_xdg_positioner(&self) -> wlc::Main<xdg_positioner::XdgPositioner> {
        match self.inner.upgrade() {
            None => panic!("unable to acquire underlying compositor to create an xdg positioner"),
            Some(c) => c.get_xdg_positioner(),
        }
    }

View on GitHub (pinned to 0f8b1195e4)