Skip to content

fix(sessionlock): wait for first frame by screenlocker client - #1215

Open
Lubsch wants to merge 1 commit into
mangowm:mainfrom
Lubsch:session-lock-wait
Open

fix(sessionlock): wait for first frame by screenlocker client#1215
Lubsch wants to merge 1 commit into
mangowm:mainfrom
Lubsch:session-lock-wait

Conversation

@Lubsch

@Lubsch Lubsch commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Context

The Session lock protocol1 requires us to ensure that we display frames by the screenlocker on all outputs before sending "locked", which we do by blanking all monitors to be gray (locked_bg). This can be circumvented with the allow_lock_transparent option but it's off by default (see #448)

Issue / Fix

I've set up my screenlocker to run before suspend. I've noticed a problem using mango: The gray blank frame is shown on wake up because it was the last one to be drawn before sleeping. Then, on my machine, it persists for a few hundred milliseconds (normal wakup freeze) before reaching the screenlocker. This looked pretty jarring to me, going from black to gray to my screenlocker. Following "every frame is correct", I think this should be improved. This change makes mango wait for the first frame by the screenlocker and only then send "locked". If allow_lock_transparent is on, it keeps the old behavior (locking immediately).

This change diverges from the spec1:

The compositor may wait for the client to create and render session lock surfaces before sending the locked event to avoid displaying intermediate blank frames. However, it must impose a reasonable time limit if waiting and send the locked event as soon as the hard requirements described above can be met if the time limit expires. Clients should immediately create lock surfaces for all outputs on creation of this object to make this possible.

We don't have a timer as the spec would require. But a screenlocker not sending frames after requesting a lock is very unlikely and because we render blank frames (locked_bg), it's not a security concern. We could add a timer later but I decided against that code weight for now.

Footnotes

  1. https://wayland.app/protocols/ext-session-lock-v1#ext_session_lock_v1 2

@Lubsch
Lubsch force-pushed the session-lock-wait branch from 482b722 to cb1c1d9 Compare July 24, 2026 00:25
Context:
The Session lock protocol
(https://wayland.app/protocols/ext-session-lock-v1#ext_session_lock_v1)
requires us to ensure that we display frames by the screenlocker on all
outputs before sending "locked", which we do by blanking all monitors to
be gray (`locked_bg`). This can be circumvented with the
`allow_lock_transparent` option but it's off by default.

I've set up my screenlocker to run before suspend. I've noticed a
problem using mango: The gray blank frame is shown on wake up because
it was the last one to be drawn before sleeping. Then, on my machine,
it persists for a few hundred milliseconds (normal wakup freeze)
before reaching the screenlocker. This looked pretty jarring to me,
going from black to gray to my screenlocker. Following "every frame is
correct", I think this should be improved.

This change makes mango wait for the first frame by the screenlocker and
only then send "locked". If `allow_lock_transparent` is on, it keeps the
old behavior (locking immediately).

This change diverges from the spec:
> The compositor may wait for the client to create and render session lock
> surfaces before sending the locked event to avoid displaying
> intermediate blank frames. However, it must impose a reasonable time
> limit if waiting and send the locked event as soon as the hard
> requirements described above can be met if the time limit expires.
> Clients should immediately create lock surfaces for all outputs on
> creation of this object to make this possible.

We don't have a timer as the spec would require. But a screenlocker not
sending frames after requesting a lock is very unlikely and because we
render blank frames (`locked_bg`), it's not a security concern. We could
add a timer later but I decided against that code weight for now.
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.

1 participant