Skip to content

Wayland: every show of a layer overlay blocks the event thread until the compositor configures it, up to 2 s #2454

Done

Description

@purian23

A hide destroys a layer overlay's surface, so every show makes a new LayerSurface, and LayerSurface::new waits for the first configure before it returns: it commits, then polls winit's display in wait_for_configure for up to configure_wait::TIMEOUT = 2 s (platform/layer_shell.rs:825-831, platform/layer_shell_machine.rs:387; the wait is pinned by your configure_wait_bounds_silent_and_chatty_compositors_and_handles_retries). Surfaces shown in one turn wait one after another, and nothing else runs meanwhile: other surfaces' frames, input, timers. When the 2 s run out, new returns None and the overlay is given up.

How long that is depends on the compositor. Hyprland defers a lock surface's configure: with two outputs, 0.5 ms and 81 ms, and locked 157 ms after the request (436 ms when we first measured it, #696). A surface per output for a lock, or a bar per output at startup, waits that long for each in turn.

Proposal: make the first configure an event like the later ones. new commits, flushes and returns; the overlay holds the surface with no GPU surface and draws nothing until the configure comes through the normal turn, which #1820's wake already delivers. No deadline is needed: every other end is already an event (closed, the output's removal, a dead connection).

We carry this. With it, across 20 popout shows and a bar start, the longest poll between a show and its return: none. In all 31 shows traced (1 bar, 20 popouts, 10 launchers) there is no poll, ppoll or recvmsg between get_layer_surface and the thread's next epoll_pwait; the longest such window is 3.0 ms. Its tests: a_layer_surface_is_made_without_waiting_and_takes_a_buffer_once_its_first_configure_comes, a_layer_surface_closed_or_left_by_its_output_before_its_first_configure_ends_without_one.

Activity

  1. Hona commented on Nov 27, 2026

    @Hona
    Member

    Fixed in PR #2629 (0c289f754).

    Design decision:

    • Removed the blocking up-to-2 s wait_for_configure poll(2) loop from LayerSurface::new. Creating a Wayland layer surface now sends its initial bufferless commit, flushes without blocking, and returns immediately.
    • Added an explicit overlay::layer_configure state machine and PendingLayer slot on OverlayCore that holds the unconfigured LayerSurface with no GPU surface until the compositor's first configure arrives via normal wake_on_wayland_read turns, then attaches the GPU surface and draws immediately.
    • Left initial configure without an artificial 2 s deadline (matching WaylandResize, HideSync, and frame_callback) so compositors that defer configure on locked or DPMS-off outputs do not lose their overlays; early zwlr_layer_surface_v1.closed, bound-wl_output wl_registry.global_remove, fatal display errors, and hide/display-change/close all end the wait cleanly as events.

    Verification:

    • Verified locally on Windows: cargo check -p rune --lib, cargo check -p rune --lib --target wasm32-unknown-unknown, and focused unit/integration tests (layer_configure, layer_shell_machine, pipe_read, overlay::keys, and overlay::, all passing).
    • Added mock-Wayland Unix-socket tests (platform/layer_shell/configure_tests.rs) covering non-blocking LayerSurface::new, pre-configure scale + configure/ack_configure, and early closed, bound-output global_remove, and socket hangup (run in Linux CI).
    • Not verified locally on live Wayland compositor hardware (Hyprland, sway, niri, or KWin). Please reopen if anything still behaves unexpectedly on a real compositor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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