Skip to content

Commits to unmapped layer surfaces error after role object has been destroyed #1979

@wmww

Description

@wmww

Originally from wmww/gtk4-layer-shell#119. GTK4 Layer Shell (a library I maintain) does some weird but technically legal things with the layer shell protocol due to how it interacts with GTK. In this case it calls:

  1. zwlr_layer_surface_v1.destroy()
  2. wl_surface.attach(NULL, 0, 0)
  3. wl_surface.commit()

Which I believe should be allowed, however Smithay errors the client with "width 0 requested without setting left and right anchors".

Side note: this only happens on the native Rust Wayland stack, the libwayland once silently drops the error (I think because the error is being sent on a dead Wayland object).

Repro

  1. Install ghostty (it uses GTK4 Layer Shell)
  2. Put keybind = global:cmd+backquote=toggle_quick_terminal in ~/.config/ghostty/config
  3. Run cargo run -p anvil --no-default-features --features winit -- --winit
  4. Run ghostty inside anvil
  5. Press Super+` to bring up the quick terminal (uses layer shell)
  6. Press Super+` again
  7. Note the the client is killed and main window appears, instead of just the quick terminal closing

Root Cause

I had my Claude investigate and she thinks the the problem is pre_commit_hook getting run after the layer surface object is destroyed. Indeed wmww@6a18fc4 appears to fix the bug, but I'm unconvinced this is the correct solution. Just adding a check seems like a hack, and this approach doesn't seem to apply as cleanly to XDG surface types, which also appear to have the same problem (untested).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions