Skip to content

Lock screen: give the first wake after a blank a 15-second grace - #17544

Open
AnPod wants to merge 3 commits into
omacom:quattrofrom
AnPod:fix/issue-17453
Open

AnPod wants to merge 3 commits into
omacom:quattrofrom
AnPod:fix/issue-17453

Conversation

@AnPod

@AnPod AnPod commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17453

Problem

On a locked display that has been DPMS-blanked, the first wake input (mouse move or key press) re-armed the 5-second idle blank timer immediately at input time. Panels take seconds to actually light up after DPMS off, so the countdown could expire and reblank the screen before the user managed to type anything — sometimes requiring repeated input for ~10 seconds before the password could be entered.

Fix

  • The first wake after a blank now arms a 15-second grace (idleBlankTimer.wakeMs) instead of the 5-second idle interval, so there is time to see the unlock screen and start typing.
  • No arm can shorten a longer pending countdown: bursts of wake input keep the already-armed deadline, and the 15-second resume countdown (resumeMs) survives the output re-detection and wake input that fire within a second of a real resume — previously a no-arg re-arm overwrote it with the 5-second idle run-up, blanking the panel ~5 s after resume (review timeline).
  • Once the grace has been consumed and the display blanked again, the next wake gets the grace again; the normal 5-second idle blanking and the hold while a password check is in flight are unchanged.
  • beginLock() and finishUnlock() reset the grace state so no lock cycle inherits a stale one; a password check in flight still holds the display up and re-arms the 5-second run-up when it ends.

Test

  • test/shell.d/fixtures/lock-fingerprint-service/shell.qml gains four wake assertions: grace on the first wake after a blank, a burst of wake input keeps the deadline, a wake after the grace was consumed returns to the 5-second interval, and a fresh grace after the next blank. The fixture needs quickshell + a compositor, so the test skips on headless boxes.
  • bash -n and shellcheck clean on the touched test script; the JS of the touched QML functions parses with node --check.

Follow-up (greptile P2)

097f97d05 tightens the fixture so a burst of wake input must keep the exact 15s grace deadline (not merely >=). The later wake is modeled 7s after the first so a re-granting regression fails the equality check.

Moving the mouse or pressing a key on a locked, blanked display wakes the
panel, but panels take seconds to light up after DPMS off. Waking armed the
standard 5-second idle interval immediately at input time, reblanking before
users could finish typing their password.

Grant a 15-second grace on the first wake after blanking, and preserve that
deadline across bursts of subsequent wake events so mouse movements cannot
shorten the grace back to five seconds before the user can type.

Fixes omacom#17453.
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with one non-blocking test improvement.

Findings

  1. P2 Password-check case misses remaining grace ▶

Summary

Gives the first wake after a blank a 15-second countdown and preserves longer running countdowns across further wake input.

  • The lock screen gets more time after each display wake.

Reviews (3) · Last reviewed commit: "Never let an idle arm shorten a pending ..." · Reviewed by Greptile

The burst check accepted any deadline at or past the first wake's, so
restarting the full 15s grace on every burst wake would pass. Shift the
armed grace back 7s before the burst so a re-granted deadline lands
strictly later, and require armedAt + interval to equal the first wake's
deadline.
@teuteuguy

Copy link
Copy Markdown

Root cause and a 3-line fix, measured on a MacBookPro11,5 (Omarchy 4.5.0-3, no fingerprint reader, session locked and blanked before suspend):

The 15 s resume grace is armed: lock() → noteSleepRequested() → fingerprintResumeTimer sees the clock jump → armBlankTimer(resumeMs). But within a second of resume, a wake path calls armBlankTimer() with no argument: onScreensChanged when outputs are re-detected, or runWake(). That overwrites the pending 15 s countdown with the 5 s default, so the panel lights ~1.4 s after resume and blanks ~5 s later (timeline in #17042).

Making armBlankTimer() never shorten a longer countdown that's still pending fixes it without touching any caller:

  function armBlankTimer(delayMs) {
    var want = delayMs || idleBlankTimer.idleMs
    if (idleBlankTimer.running && idleBlankTimer.armedAt + idleBlankTimer.interval - Date.now() > want) return
    idleBlankTimer.interval = want
    idleBlankTimer.armedAt = Date.now()
    idleBlankTimer.restart()
  }

Same machine with this patch (dpmsStatus polled every 200 ms across an RTC-woken S3 cycle):

14:20:44.40  kernel: Waking up from system sleep state S3
14:20:45.07  kernel: PM: suspend exit
14:20:45.65  eDP dpms on   (lock screen visible)
14:21:00.33  eDP dpms off  (14.7 s later, was 5 s)

Input still behaves as before: once the grace has less than 5 s left, a keypress re-arms the normal 5 s. The display is never blanked earlier than today. Only the blank timing changes; locking itself is untouched.


How this was produced: this comment was written by Claude Opus 5.5 (Anthropic's AI model), working as an autonomous agent on my behalf, and is posted with my approval. Method: hardware-in-the-loop testing on my own MacBookPro11,5. An Ubuntu mini-PC drove the Mac over SSH (Tailscale) and through a JetKVM (HDMI capture + USB HID keyboard for login and remote wake). A scripted S3 harness armed an RTC alarm (or sent a USB HID wake), suspended with systemctl suspend, waited for the Mac to return, then pulled the kernel journal for that cycle (journal cursor) and counted ring/IB/UVD results, GPU lockup/stall lines, si_dpm errors and brcmf failures into a JSONL log. Mesa builds (26.2.5 + patch, stock 26.0.8) were compiled in an Arch container and loaded only from a private prefix via LIBVA_DRIVERS_PATH. Nothing was installed system-wide. Decode tests used ffmpeg -hwaccel vaapi on generated 1080p30 clips. I did the physical power-button presses when the machine froze.

Guard armBlankTimer so a shorter delay does not cut short a longer pending
countdown, replacing the graceDeadline mechanism. This fixes the resume-grace
overwrite from PR review (teuteuguy's timeline: resume arm 15s -> screensChanged
or runWake no-arg re-arm 5s).

Update the lock fingerprint service test fixture to cover resume grace
preservation across output re-detection and wake bursts, as well as the
stopped-timer re-arm semantics.
@AnPod

AnPod commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed d584b10 addressing this — thanks for the hardware-tested timeline, it made the failure mode unambiguous.

armBlankTimer() now never shortens a longer countdown that is still pending: a no-arg arm early-returns while armedAt + interval - Date.now() exceeds the requested 5 s idle run-up, and once less than that remains it re-arms the normal 5 s exactly as you described. The two resume arms (armBlankTimer(resumeMs) from the suspend-gap detection and the fingerprint-slept path) needed no other change — their pending 15 s is now protected by the guard itself. The PR draft's graceDeadline bookkeeping was deleted outright: the timer's own armedAt + interval is the single record of the pending fire time, which is what made the interaction between the wake grace and the resume arms confusing in the first place.

Your other invariant is pinned by fixture assertions: the display never blanks earlier than before, and input once the grace is mostly spent re-arms the 5 s run-up. One deliberate divergence from your patch snippet, noted in the review: with the timer stopped during a password check, a no-arg arm re-arms 5 s rather than restoring an older deadline — the user is interacting by definition at that point, which is the grace doing its job. The lock-fingerprint-service fixture gained the resume-timeline assertions (they skip headless, so the review verified them by fake-clock simulation: red on the previous head exactly at your screensChanged/runWake scenario, green with the guard).

Comment on lines +264 to +266
blankTimer.stop()
service.runWake()
check(blankTimer.interval === 5000, "input ending a password check arms the normal 5s run-up even with grace left over")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Password-check case misses remaining grace

The preceding check has already changed blankTimer.interval to 5000. Stopping that timer and calling runWake() does not test the claimed case “even with grace left over.” A regression that restores the remaining 15-second grace after a password check would still pass.

Arm a fresh 15-second grace before stopping the timer, then check that ending the password check starts the normal 5-second countdown.

@aholbreich

Copy link
Copy Markdown
Contributor

This looks like the fix to land for the early re-blank. It keeps fixed timings, no setting (DHH ruled a setting out on #6642), and it also stops a plain re-arm from cutting the 15 s resume grace from #17277 back to 5 s. Same problem as #7399, #7749, #15759, #17042, #17228 and #18926, plus #11411 and #14905 after resume.

The visual-evidence check fails because the description has no recording and no No visible change: <reason> line. Adding either should clear it.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 High in Codex read the diff, discussion, linked issue #17453 and base-branch rules. I classified this as a bug fix, but the classification model, deepseek-v4p1-flash, returned no class, leaving classification unsettled. No full code review or worker tests ran, and no labels were added; this is waiting on a classification decision before verification.

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.

Locked display reblanks five seconds after wake input, before the user can type

4 participants