Repository navigation
fix: fingerprint lid open - #3448
Conversation
|
/claude review |
| readonly property int verifyStartSlackMs: 10000 | ||
| readonly property bool retrying: errorRetry.running | ||
| readonly property int retryInterval: errorRetry.interval | ||
| readonly property bool allowed: available && SettingsData.enableFprint && root.lockSecured && !root.fprintSuppressedByPrimaryPam && !root.unlockInProgress && !root.u2fPending && !SessionService.preparingForSleep && !IdleService.monitorsOff && tries < SettingsData.maxFprintTries |
There was a problem hiding this comment.
!IdleService.monitorsOff in allowed makes touching the sensor a no-op on a blanked lock screen.
Fingerprint readers are libfprint USB devices, not evdev input devices, so a scan produces no seat activity. The only paths that clear monitorsOff are input-driven (lockWakeMonitor in IdleService.qml:154, lockWakeDebounce behind the MouseArea in Lock.qml:463-489). So on a locked laptop with the screen off, the user now has to press a key or move the mouse before the reader is re-claimed — previously the scan alone woke and unlocked it.
The suspend wedge you're fixing is covered by !SessionService.preparingForSleep, which is already in this binding. Gating on monitorsOff too also releases the reader during plain DPMS blanking, where nothing is going to wedge it. Dropping !IdleService.monitorsOff keeps the suspend fix and the scan-to-wake behavior; if you want to keep it, it's worth calling out in the PR description and the docs since it's a visible change for laptop users.
There was a problem hiding this comment.
Measured this instead of arguing it. Goodix 27c6:6594, fprintd 1.94.5, G_MESSAGES_DEBUG=all on the daemon and debug on pam_fprintd. Locked screen with the monitors on, so monitorsOff was false and !SessionService.preparingForSleep was the only guard in play - the arrangement you are proposing.
19:07:42.004 pam: VerifyStart completed / "Waiting for 89 seconds"
19:07:58.656 fprintd: Preparing devices for sleep
19:07:58.656 fprintd: suspend completion (error: FP_DEVICE_ERROR_NOT_SUPPORTED)
19:07:58.659 fprintd: Device reported an error during verify: Cannot run while suspended.
19:07:58.661 pam: ReleaseDevice failed: The device is still busy with another operation
19:08:02.812 kernel: PM: suspend entry (s2idle)
fprintd holds its own delay inhibitor and suspends the device about a millisecond after PrepareForSleep. The kernel only suspended 4.1 seconds later, so this is not a race the shell lost by being slow - both sides start from the same signal, fprintd's handler is in-process, and our path is dbus -> core -> socket -> QML -> killing the PAM child. We cannot get in front of it, and an inhibitor of our own would not order us ahead either.
So !SessionService.preparingForSleep does not prevent the wedge at all. It only stops us re-arming across the sleep. The one thing that does prevent it is not having a verify running when the suspend starts, which is what !IdleService.monitorsOff buys on the idle path, where the blank always comes before the idle suspend.
What dropping the gate costs, from the same run:
19:08:11.762 PM: suspend exit
19:08:12.324 attempt 1 -> failed to claim: The device has already been opened!
19:08:14.764 attempt 2 (1.5s backoff) -> same
19:08:44.848 fprintd exits, 30s after the last client detached
19:08:49.977 attempt 3 (35s backoff) -> fresh daemon, claim ok
19:08:52.810 verify-match
39 seconds of dead reader after every idle suspend, for the same users who would get the scan-to-wake back.
Root cause behind all of it, for the record: goodixmoc answers a suspend during a verify with FP_DEVICE_ERROR_NOT_SUPPORTED, libfprint cancels the operation, and fprintd keeps the device open, so PAM's Release can no longer succeed. A reader whose driver supports suspend would not wedge at all.
The behavior change you flagged is real and was not documented - that part is fixed. It is also worse than the comment says for lockScreenPowerOffMonitorsOnLock users: applyMonitorsOff() runs at lock time (Lock.qml:51), so the reader is never claimed after locking until the screen is woken once. Both are now in the PR description, along with the trace above.
Claude reviewSolid, well-tested rework of the fingerprint lifecycle — one behavior consequence worth deciding on deliberately.
Checked: fprint state machine (allowed/status/startAttempt/scheduleErrorRetry recursion and backoff bounds), the Failed/MaxTries and attemptSettled paths, timer lifetimes on stop/reset/unlock, the new UPower lid subscription against the core dbus signal payload shape and match-rule filtering, LockSurface handler grabs, and the PAM profile/Go-test/Makefile changes. Model: claude-opus-5. |
The reader stopped responding after the lid was closed and opened, after a long idle period, and after suspend. The shell held a PAM session for as long as the screen was locked, so a suspend always landed on a running verify. fprintd then suspends the device under the verify, pam_fprintd's ReleaseDevice fails with "device is still busy", and the claim is never released, so every later Claim fails until fprintd restarts. The reader is now released when the monitors blank and armed again when they come back, so a suspend has nothing left to wedge. The PAM profile drops to max-tries=1 and sets an explicit timeout. pam_fprintd only counts a wrong finger, so one finished session is now one wrong scan and maxFprintTries means the number of scans it names rather than five times that. A timeout expiry arrives as PamResult.Error, exactly like a device fault, so a session that ran at least as long as the configured timeout is treated as a planned renewal instead of spending the error budget and painting an error. A suspend that still lands while the screen is on wedges as before. Recovery now waits out fprintd's idle timeout instead of climbing to it, which brings the reader back about 37 seconds after resume instead of about 98. SessionService gains lidOpened from UPower, because logind can ignore the lid on AC and resume alone is not enough. The lock PAM state machine is fixed alongside: PamResult.Failed was dropped, a pending retry outlived the contexts that owned it, and an availability check reset the wrong-scan counter. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q5LQHivuucTLXwLkvZMfcn
pam_fprintd's timeout runs from the verify, but the session age was measured from start(), which folds the claim into it. A slow claim plus a verify that failed before its own timeout could add up past the timeout and be taken for a planned renewal, skipping the backoff. A session that never reached a verify had the same problem. The age now starts at the message pam_fprintd sends when the verify begins, so a session that never verified can never qualify as an expiry, and a slow claim no longer ages a fault. The message is translated and quickshell clears it before completed, so only its timing is used, never its text. That message arrives after pam_fprintd has already armed its deadline, because VerifyStart is asynchronous, so the age read here runs short of the real timeout and a slack makes it up. The bias is deliberate. A fault misread as a timeout costs one extra retry, while a timeout misread as a fault parks the reader behind a backoff that grows to a minute, which on an idle lock screen would leave it unusable most of the time. Also corrects the comment that claimed a timeout is reported without a message. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q5LQHivuucTLXwLkvZMfcn
81dc252 to
235d4fb
Compare
|
/claude review |
Claude reviewNo issues found. The earlier Checked: fprint |
* lock: keep the fingerprint reader usable across suspend The reader stopped responding after the lid was closed and opened, after a long idle period, and after suspend. The shell held a PAM session for as long as the screen was locked, so a suspend always landed on a running verify. fprintd then suspends the device under the verify, pam_fprintd's ReleaseDevice fails with "device is still busy", and the claim is never released, so every later Claim fails until fprintd restarts. The reader is now released when the monitors blank and armed again when they come back, so a suspend has nothing left to wedge. The PAM profile drops to max-tries=1 and sets an explicit timeout. pam_fprintd only counts a wrong finger, so one finished session is now one wrong scan and maxFprintTries means the number of scans it names rather than five times that. A timeout expiry arrives as PamResult.Error, exactly like a device fault, so a session that ran at least as long as the configured timeout is treated as a planned renewal instead of spending the error budget and painting an error. A suspend that still lands while the screen is on wedges as before. Recovery now waits out fprintd's idle timeout instead of climbing to it, which brings the reader back about 37 seconds after resume instead of about 98. SessionService gains lidOpened from UPower, because logind can ignore the lid on AC and resume alone is not enough. The lock PAM state machine is fixed alongside: PamResult.Failed was dropped, a pending retry outlived the contexts that owned it, and an availability check reset the wrong-scan counter. * lock: time the fingerprint session from the verify, not the claim pam_fprintd's timeout runs from the verify, but the session age was measured from start(), which folds the claim into it. A slow claim plus a verify that failed before its own timeout could add up past the timeout and be taken for a planned renewal, skipping the backoff. A session that never reached a verify had the same problem. The age now starts at the message pam_fprintd sends when the verify begins, so a session that never verified can never qualify as an expiry, and a slow claim no longer ages a fault. The message is translated and quickshell clears it before completed, so only its timing is used, never its text. That message arrives after pam_fprintd has already armed its deadline, because VerifyStart is asynchronous, so the age read here runs short of the real timeout and a slack makes it up. The bias is deliberate. A fault misread as a timeout costs one extra retry, while a timeout misread as a fault parks the reader behind a backoff that grows to a minute, which on an idle lock screen would leave it unusable most of the time. Also corrects the comment that claimed a timeout is reported without a message. --------- (cherry picked from commit d7074a5)
Description
The fingerprint reader on the lock screen stops responding: after the lid is
closed and opened, after a long idle period, and after suspend.
The shell held a PAM session and a claimed fingerprint device for as long as the
screen was locked, so a suspend always landed on a running verify. That is what
breaks fprintd: it suspends the device under the verify,
ReleaseDevicethenfails with "device is still busy", and the claim is never released. Every later
attempt fails until fprintd restarts, which it only does after 30 seconds with no
client attached.
The main fix is to release the reader when the monitors blank and arm it again
when they come back. A suspend then has nothing to wedge, and a locked laptop no
longer holds a subprocess and the reader open all night.
Why the reader has to be released before the suspend, not during it
Traced on a Goodix 27c6:6594 with fprintd 1.94.5,
G_MESSAGES_DEBUG=allon thedaemon and
debugonpam_fprintd, locked with the monitors on:fprintd holds its own delay inhibitor and suspends the device about a millisecond
after
PrepareForSleep, while the kernel only suspends 4.1 seconds later. Theshell cannot get in front of that: both sides start from the same signal,
fprintd's handler is in-process, and the shell's path is dbus to core to socket
to QML to killing the PAM child. So
SessionService.preparingForSleepis not aguard against the wedge, only a way to stop re-arming across the sleep. Not
having a verify running when the suspend starts is the only thing that works.
The underlying fault is a driver one: goodixmoc answers a suspend during a verify
with
FP_DEVICE_ERROR_NOT_SUPPORTED, libfprint cancels the operation, and fprintdis left with the device open, so
Releasefrom PAM can no longer succeed. A readerwhose driver supports suspend would not wedge.
Behavior change
A scan on a blanked lock screen no longer wakes or unlocks the machine. The reader
is a USB device, not an input device, so a scan produces no seat activity and
cannot clear
monitorsOffon its own - the screen has to be woken with a key orthe pointer first, and the reader is armed again as soon as it is.
This is visible for anyone with a monitor timeout configured, and more so with
lockScreenPowerOffMonitorsOnLockenabled: the monitors blank at lock time, sothe reader is not claimed after locking until the screen is woken once.
The trade in the other direction: with the reader still claimed when the machine
suspends, the wedge costs about 39 seconds after resume before it answers again,
measured on the same run:
Alongside that:
max-tries=5tomax-tries=1.pam_fprintdcounts only a wrong finger, and nothing in the UIshows its messages, so under
max-tries=5the first four wrong scans producedno feedback at all and the fifth read "Fingerprint not recognized (1/15)". Each
wrong scan now ends the session, so each one is reported and the counter is
right. It also means
maxFprintTriesis a number of scans rather than ofgroups of five: with the default of 15 the lockout arrives after 15 wrong
scans instead of 75. Anyone who lowered the setting will reach it sooner. On
fprintd 1.90.x the minimum for
max-triesis 3, so there it keeps the oldgrouping.
timeout=90in the profile. fprintd defaults to 30 seconds,which is short enough that a lock screen spends a good part of its time between
sessions rather than scanning. 90 leaves room without letting a stuck session
hold the reader indefinitely.
pam_fprintdreports an expiredtimeout exactly like a device fault, so waiting without a finger used to spend
the retry budget and paint "Fingerprint error". The shell now tells them apart
by how long the verify ran.
SessionService.lidOpened, from UPower, because logind can ignore the lidon AC and resume alone is not enough.
fprintd's idle timeout, since only its restart clears a wedged device. The old
exponential steps kept re-attaching and resetting that timer.
PamResult.Failedwas dropped, a pendingretry outlived the contexts that owned it, an availability check reset the
wrong-scan counter, parallel attempts were possible, and a pending retry was
drawn as an active scanner.
Type of change
Related issues
Fixes #3403
Screenshots / video
Checklist
I18n.tr()with translator context, reusing existing terms where possiblemake fmt, added/updated tests,make testpasses, andgo mod tidyis cleanmake lint-qmlwith no new warningsGenerative AI
Significant parts of this change were written with LLM assistance (Codex and
Claude Code). I have read, tested and can explain every line.