fix(session): wait for lock screen to render before suspending#3125
fix(session): wait for lock screen to render before suspending#3125Aitor42 wants to merge 4 commits into
Conversation
|
Hey @Aitor42 , thanks for tackling this, the direction looks good to me. The race is real: I'd want a timeout fallback before merge though. If a surface never renders, suspend could hang forever. A 2-3s timer that warns and runs the callback anyway is a reasonable tradeoff. Minor nits: the flush-when-ready logic is duplicated in three places (a Manual testing is fine here. Nice work overall. |
Thanks for the feedback! I added the timeout to 3 seconds and the tryFlushPendingAfterLocked() function. For the firstFrameRendered rest I only change it when a real geometry change occurs, preventing unnecessary re-blocking of the flush during non-sizing configure events. Let me know if you see something else. |
Summary
This PR ensures that the deferred suspend command is executed only after all active lock screen surfaces have successfully drawn and committed their first frame.
render()inLockSurfaceto track whenm_firstFrameRenderedis set totrueand trigger a render callback.allSurfacesReady()inLockScreento verify if all output surfaces have completed their first render.runAfterSessionLockedandhandleLockedto defer execution of the pending suspend callback untilallSurfacesReady()is true.Motivation
This resolves a race condition where the system suspends before the lock screen has finished rendering. When resuming, the unlocked desktop could briefly flash or remain visible, presenting a security vulnerability and visual glitch.
Type of Change
Related Issue
Closes #2962
Testing
Built the daemon and ran the entire test suite:
meson compile -C build
meson test -C build
All tests pass successfully.
Manual Coverage
Checklist
CONTRIBUTING.md.just formatwith clang-format v22+ installed, or this PR has no code changes.assets/translations/en.json, or this PR adds no new user-facing strings.Additional Notes
If a lock surface fails to configure or render due to driver glitches or compositor-specific edge cases, the suspend sequence could get indefinitely postponed. I sugest adding a 2-3 second fallback timer to trigger suspend regardless of render status.