Skip to content

fix: crash on implicit unwrapped optional - WPB-26725#4947

Draft
netbe wants to merge 1 commit into
release/cycle-4.16from
fix/crash-applock
Draft

fix: crash on implicit unwrapped optional - WPB-26725#4947
netbe wants to merge 1 commit into
release/cycle-4.16from
fix/crash-applock

Conversation

@netbe

@netbe netbe commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator
BugWPB-26725 [iOS] App crashing when tapping on notification from group for inactive account

Issue

  • AppLockModule.Interactor.handleAuthenticationResult dispatches its result to the main queue guarding only [weak self], while its presenter property is a weak, implicitly-unwrapped optional (AppLockPresenterInteractorInterface!) that isn't guarded.
  • The app-lock module can be torn down and rebuilt mid-flight: AppRootRouter.showAppLock rebuilds a fresh AppLockModule.View/Presenter/Interactor every time the app state re-enters .locked (e.g. when the Face ID/Touch ID/passcode system prompt briefly resigns the app). The old Interactor is kept alive by the pending LocalAuthentication callback closure, but its Presenter (owned only by the now-discarded View) gets deallocated, zeroing the weak presenter reference.
  • When the stale callback later fires with .denied, .needCustomPasscode, or .unavailable, the code force-unwraps the nil presenter → EXC_BREAKPOINT / "Unexpectedly found nil while implicitly unwrapping an Optional value" crash (confirmed via crash.log, matches Thread 0 crash + Thread 14's LAContext completion path).

Fix: guard let self, let presenter else { return } in the dispatched closure — mirrors an existing pattern already used elsewhere in the codebase (ImagePickerManager.swift, AudioTrackPlayer.swift, ConversationListViewController+NavigationBar.swift). Stale/orphaned callbacks now no-op instead of crashing.

File changed: Wire-iOS/Sources/UserInterface/App Lock/AppLockModule.Interactor.swift (1 line)

Testing

account A and B are logged in, A is the active account
app is int he background
B receives a notifcation from a group
B tapps on the notification -> app crashes


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

@netbe netbe changed the title fix crash on implicit unwrapped optional fix: crash on implicit unwrapped optional Jul 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@netbe netbe changed the title fix: crash on implicit unwrapped optional fix: crash on implicit unwrapped optional - WPB-26725 Jul 1, 2026
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