Skip to content

Fix Auth Glitches Android#455

Merged
n13 merged 6 commits intomainfrom
no-auth-when-logged-out
Apr 19, 2026
Merged

Fix Auth Glitches Android#455
n13 merged 6 commits intomainfrom
no-auth-when-logged-out

Conversation

@n13
Copy link
Copy Markdown
Collaborator

@n13 n13 commented Apr 19, 2026

user is on welcome screen - no auth needed

May fix the android flicker for new users

AI analysis:

Good news — all three videos confirm the same root cause, just manifesting differently across devices. Here's the updated analysis:


Video 2 (11.41.23): The system biometric dialog stays stable on screen, but the app's own UI behind it flickers. The AuthWrapper lock screen appears and disappears behind the dimmed overlay. This is the isAuthenticated state bouncing — checkAuthentication() keeps setting isAuthenticated: true (its else branch) while the pending authenticate() call then sets it back to false when it resolves with a failure.

Video 3 (11.41.27): Shows the Welcome screen ("Create Wallet" / "Import Wallet") with a "Welcome back" bottom sheet (fingerprint + "Use PIN") looping at ~1Hz. That bottom sheet is the OEM-styled Android biometric prompt (Samsung/Xiaomi/etc. customize its appearance as a bottom sheet). Same loop: prompt appears → inactiverecordBackgroundTime() starts async → resumed fires before it completes → checkAuthentication() reads stale lastPausedTime → triggers authenticate() again → new prompt → repeat.

All three fit the same theory. The fix I already applied should handle all cases:

    } else {
      // Handle background states (inactive, paused, hidden, detached)
      // Skip if the biometric dialog caused this lifecycle change — on some
      // Android devices the prompt triggers inactive→resumed oscillation.
      if (!_isBackgrounded && !ref.read(localAuthProvider).isAuthenticating) {
        print('AppLifecycleState.$state - pausing (update pause time only)');
        _isBackgrounded = true;

        pollingManager.pausePolling();
        localAuthNotifier.recordBackgroundTime();
      } else {
        print('AppLifecycleState.$state - already backgrounded, skipping actions');
      }
    }

Why this single fix covers all three scenarios:

When isAuthenticating is true (biometric dialog is showing), the else branch is completely skipped. This means:

  • _isBackgrounded stays false
  • recordBackgroundTime() is never called (no stale lastPausedTime race)
  • When the device oscillates back to resumed, the if (_isBackgrounded) guard on line 88 blocks checkAuthentication() from running

The biometric flow then proceeds normally: authenticate() awaits the system prompt, user scans their finger (or cancels), and the result is handled without interference. No more lifecycle-triggered re-entry into the auth flow.

@n13 n13 changed the title disable auth when there is no wallet Fix Auth Glitches Android Apr 19, 2026
@n13 n13 merged commit 3c66058 into main Apr 19, 2026
1 check passed
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