Skip to content

fingerprint: retry device connection/claim when fprintd is not running - #1095

Open
MRAOFeb wants to merge 2 commits into
hyprwm:mainfrom
MRAOFeb:fingerprint-start-verify-retry
Open

MRAOFeb wants to merge 2 commits into
hyprwm:mainfrom
MRAOFeb:fingerprint-start-verify-retry

Conversation

@MRAOFeb

@MRAOFeb MRAOFeb commented Nov 7, 2026 •

Copy link
Copy Markdown

Summary

Fingerprint authentication silently and permanently fails if fprintd is not yet running when the session is locked. Since fprintd.service is D-Bus-activated (starts on first use, exits after ~30s idle), this is common right after boot/resume - exactly when users hit the lock screen.

Previously CFingerprint::startVerify() had three failure paths, and none of them retried:

  1. createDeviceProxy(): GetDefaultDevice throws while fprintd is being D-Bus-activated -> return, nothing restarts it;
  2. claimDevice() failure -> WARN log only;
  3. VerifyStart failure on the initial call -> WARN log only.

After any of these, m_sDBUSState.verifying stayed true, no verification was running, and the only recovery was re-locking the screen or suspend/resume.

Changes

  • Retry the whole startVerify() chain (device proxy -> claim -> VerifyStart) with its own exponential backoff - 500 ms -> 1 s -> 2 s (up to 3 retries after the initial attempt, i.e. 4 attempts in total), sized to cover the typical 1-3 s cold D-Bus activation window of fprintd after boot. This keeps auth:fingerprint:retry_delay (semantically about no-match retries) untouched. Reuses the existing g_pHyprlock->addTimer() pattern plus a new SDBUSState::startRetries counter and a MAX_START_RETRIES = 3 constant.
  • After exhausting the retries, schedule no further attempts, set verifying = false, mark the D-Bus state as done (so the PropertiesChanged/finger-present handler stops updating the prompt after auth is disabled) and call g_pAuth->enqueueFail() with a descriptive failure reason ("Fingerprint auth disabled (fprintd unavailable)" / "(failed to claim device)" / "(failed to start verification)"), so the UI shows a proper fail state instead of a stuck prompt. Password auth is unaffected.
  • startRetries is reset after a successful VerifyStart and when the retries are exhausted, so the next lock/sleep cycle gets a fresh set of attempts.
  • The existing behavior of the isRetry path (VerifyStart failure after a no-match retry: "Fingerprint auth disabled (failed to restart)") is preserved.
  • The device proxy is destroyed from a timer callback (0-timer on give-up, or lazily at the start of the retry chain) instead of directly inside the D-Bus async reply handler, to avoid freeing an sdbus::IProxy whose own callback code is on the call stack.

Test plan

  • systemctl stop fprintd (or a fresh boot), lock immediately -> retries visible in verbose logs (fprint: couldn't connect to Fprint service, retrying..., could not start verifying, retrying...) at growing intervals (0.5 s -> 1 s -> 2 s); the fingerprint works as soon as fprintd comes up, since the retry window now spans ~3.5 s.
  • With fprintd service masked: initial attempt + up to 3 retries at increasing delays, then a visible failure message ("Fingerprint auth disabled (...)" via $FPRINTFAIL), no hang, password auth unaffected.
  • Normal case unchanged: claim + verify start instantly, verify-match unlocks, no-match retry behavior (still governed by auth:fingerprint:retry_delay) untouched.

AI usage disclosure: the PR description was AI-generated (my English is
weak, so I had it write up my change). The code itself is entirely mine.

Fingerprint authentication used to fail silently and permanently if
fprintd was not yet running when the session was locked. Since
fprintd.service is D-Bus-activated, this is common right after boot or
resume: GetDefaultDevice throws while the daemon is being activated,
startVerify() returns without retrying and nothing ever restarts the
chain. Claim and VerifyStart failures had the same problem (WARN log
only).

Retry the whole start chain (device proxy -> claim -> VerifyStart) up
to MAX_START_RETRIES (3) times with auth:fingerprint:retry_delay
between attempts, reusing the same addTimer() pattern as MATCH_NO_MATCH
retries. After exhausting retries, enqueueFail() so the UI shows a
proper "fingerprint unavailable" failure reason instead of a stuck
prompt. startRetries is reset after a successful VerifyStart and when
retries are exhausted, so the next lock/sleep cycle gets a fresh set of
attempts.

The device proxy is destroyed from a timer callback (not from within
the D-Bus async reply handler) to avoid freeing an sdbus::IProxy whose
code is on the call stack.
startVerify() retries reused auth:fingerprint:retry_delay (250 ms by
default), giving ~750 ms total - shorter than the typical 1-3 s cold
D-Bus activation window of fprintd after boot, i.e. the very scenario
the fix targets. Have the start chain use its own backoff schedule
(500 ms -> 1 s -> 2 s) instead, leaving retry_delay with its original
no-match semantics.

Also set done on give-up so the PropertiesChanged finger-present
handler stops updating prompts after fingerprint auth is disabled.
@MRAOFeb
MRAOFeb force-pushed the fingerprint-start-verify-retry branch from 996c1b5 to 32dcb87 Compare November 7, 2026 17:41
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