Skip to content

fix(lock): hold sleep inhibitor until compositor confirms lock - #2907

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
tkroll-ionos:fix/lock-before-suspend-wait-secure
Jul 22, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
tkroll-ionos:fix/lock-before-suspend-wait-secure

Conversation

@tkroll-ionos

Copy link
Copy Markdown
Contributor

Fixes #2906.

Problem

lock before suspend releases the logind sleep delay inhibitor as soon as Qt reports the lock rendered (onAfterAnimating / onAfterRendering in LockScreenContent.qml). Those signals fire when Qt finishes its render pass — before the compositor has committed/presented the ext-session-lock surface. The machine then freezes ~1 frame later with the desktop still the last presented frame, and on resume the desktop is briefly visible before the lock appears (suspend and hibernate alike).

Measured on niri / s2idle (3 outputs): lockerReady was sent 18 ms before PM: suspend entry. The handshake and fallback logic in core/internal/server/loginctl/monitor.go are correct — only the readiness signal was too early.

Change

Gate lockerReady on WlSessionLock.secure — the ext-session-lock locked event, i.e. the compositor's own confirmation that the session is locked and the desktop is hidden:

  • LockSurface.qml passes the WlSessionLock down to the content as sessionLock.
  • LockScreenContent.qml maybeSend() returns early while sessionLock && !sessionLock.secure, and a Connections { onSecureChanged } re-fires the check when the compositor confirms the lock.

The Go-side 2–4 s fallback timer is unchanged as the backstop. When no lock object is present (e.g. demo mode) behavior is unchanged.

Testing

Built as an external shell dir (dms run -c) on the reporter's machine (niri, s2idle, 3 outputs), same build otherwise:

  • Before: desktop flashes on resume every cycle; lockerReady sent 18 ms before PM: suspend entry.
  • After: no flash on resume, suspend and hibernate.

Note

With multiple outputs, the Go side releases the inhibitor on the first of the N per-output lockerReady calls (handlers.go handleLockerReady). Not the cause here (all outputs reported within the same ms), but flagging it as a possible secondary race for a follow-up.

lock-before-suspend released the logind sleep delay inhibitor as soon as Qt
reported the lock rendered (afterAnimating/afterRendering). That signal fires
before the compositor has committed/presented the ext-session-lock surface, so
the machine could freeze ~1 frame later with the desktop still the last
presented frame. On resume the desktop was briefly visible before the lock
appeared (both suspend and hibernate).

Gate lockerReady on WlSessionLock.secure (the ext-session-lock `locked` event),
so the inhibitor is held until the compositor confirms the session is locked and
the desktop is hidden. LockSurface passes the WlSessionLock down as sessionLock;
the readiness check returns early until secure, and re-fires on secureChanged.
The Go-side fallback timer in loginctl monitor remains as the backstop.

Reproduced on niri / s2idle with 3 outputs: debug log showed lockerReady sent
18 ms before `PM: suspend entry`; with this change the desktop no longer flashes
on resume.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Thomas Kroll <[email protected]>
@bbedward
bbedward merged commit 237fb57 into duxlabs-dev:master Jul 22, 2026
1 check passed
@tkroll-ionos
tkroll-ionos deleted the fix/lock-before-suspend-wait-secure branch July 23, 2026 14:17
bbedward pushed a commit that referenced this pull request Jul 24, 2026
lock-before-suspend released the logind sleep delay inhibitor as soon as Qt
reported the lock rendered (afterAnimating/afterRendering). That signal fires
before the compositor has committed/presented the ext-session-lock surface, so
the machine could freeze ~1 frame later with the desktop still the last
presented frame. On resume the desktop was briefly visible before the lock
appeared (both suspend and hibernate).

Gate lockerReady on WlSessionLock.secure (the ext-session-lock `locked` event),
so the inhibitor is held until the compositor confirms the session is locked and
the desktop is hidden. LockSurface passes the WlSessionLock down as sessionLock;
the readiness check returns early until secure, and re-fires on secureChanged.
The Go-side fallback timer in loginctl monitor remains as the backstop.

Reproduced on niri / s2idle with 3 outputs: debug log showed lockerReady sent
18 ms before `PM: suspend entry`; with this change the desktop no longer flashes
on resume.

Signed-off-by: Thomas Kroll <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 237fb57)
marcusramberg pushed a commit to marcusramberg/DankMaterialShell that referenced this pull request Sep 2, 2026
…bs-dev#2907)

lock-before-suspend released the logind sleep delay inhibitor as soon as Qt
reported the lock rendered (afterAnimating/afterRendering). That signal fires
before the compositor has committed/presented the ext-session-lock surface, so
the machine could freeze ~1 frame later with the desktop still the last
presented frame. On resume the desktop was briefly visible before the lock
appeared (both suspend and hibernate).

Gate lockerReady on WlSessionLock.secure (the ext-session-lock `locked` event),
so the inhibitor is held until the compositor confirms the session is locked and
the desktop is hidden. LockSurface passes the WlSessionLock down as sessionLock;
the readiness check returns early until secure, and re-fires on secureChanged.
The Go-side fallback timer in loginctl monitor remains as the backstop.

Reproduced on niri / s2idle with 3 outputs: debug log showed lockerReady sent
18 ms before `PM: suspend entry`; with this change the desktop no longer flashes
on resume.

Signed-off-by: Thomas Kroll <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

lock-before-suspend: desktop briefly visible on resume (sleep inhibitor released before compositor presents lock surface)

2 participants