Skip to content

Conversation

@FreddyFunk
Copy link

This bug caused a Wayland layer-shell protocol violation: "must ack the initial configure before attaching buffer" which occurres when rapidly creating and destroying layer surfaces and I discovered this while working on pop-os/cosmic-settings#1554 and pop-os/cosmic-osd#151 .

Root Cause

The issue was a violation of the Wayland layer-shell protocol requirement that states configure events must be acknowledged before any buffers can be attached.
https://wayland.app/protocols/wlr-layer-shell-unstable-v1

"any attempts by a client to attach or manipulate a buffer prior to the first layer_surface.configure call must also be treated as errors"
"when a configure event is received, if a client commits the surface in response to the configure event, then the client must make an ack_configure request sometime before the commit request"

The bug had two parts:

  1. Premature frame marking (event_loop/state.rs:1060): When a layer surface was created, receive_frame() was called immediately, marking the surface with FrameStatus::Received and indicating it was ready to draw.
  2. Early redraw request (handlers/shell/layer.rs:45): configure handler was calling request_redraw() before the configure event was fully processed.

This meant layer surfaces could attempt to attach buffers before their first configure event was acknowledged, violating the protocol.

Solution

Part 1: Delay frame readiness until first configure

  • Removed the premature receive_frame() call when layer surfaces are created
  • Added receive_frame() to the configure handler, only after the configure is fully processed
  • This ensures layer surfaces are not marked as drawable until they've received and processed their first configure event

Part 2: Ensure configure processing happens before redraw

  • Moved request_redraw() to after all configure processing (viewport update, size setting, etc)
  • Added proper borrow handling by cloning wl_surface before calling request_redraw()

@wash2 wash2 merged commit d2949f2 into pop-os:master Nov 18, 2025
2 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants