Skip to content

Fix iOS crash caused by navigation race condition after Onfido exit#88184

Closed
pranjal2410719 wants to merge 1 commit intoExpensify:mainfrom
pranjal2410719:fix/onfido-ios-crash
Closed

Fix iOS crash caused by navigation race condition after Onfido exit#88184
pranjal2410719 wants to merge 1 commit intoExpensify:mainfrom
pranjal2410719:fix/onfido-ios-crash

Conversation

@pranjal2410719
Copy link
Copy Markdown

Explanation of Change

On iOS, the Onfido SDK triggers the exit callback before its native view controller has fully completed dismissal. The existing implementation immediately called onUserExit, which triggered React Navigation transitions while the native dismissal animation was still in progress.

This created a race condition between:

  • Native Onfido view controller dismissal
  • React Navigation stack updates
  • Immediate user re-entry into the flow

iOS does not allow overlapping view controller transitions, resulting in a crash.

This PR introduces a deferred exit mechanism to synchronize navigation with the completion of native interactions.


Fixed Issues

$ #88173
PROPOSAL: #88173 (comment)

Fix

  • Introduced scheduleUserExit to defer navigation on iOS
  • Used InteractionManager.runAfterInteractions to wait for ongoing interactions
  • Added requestAnimationFrame chaining to align with render cycle
  • Added instance-scoped guard (isExitInProgress) to prevent duplicate triggers
  • Implemented cleanup for scheduled tasks on unmount to prevent memory leaks
  • Ensured all Onfido exit paths use the new scheduling mechanism

Android behavior remains unchanged.


Tests

  1. Start Onfido verification flow
  2. Exit using back button
  3. Immediately tap "Pay with wallet" again
  4. Verify app does NOT crash
  5. Repeat exit multiple times rapidly
  6. Verify no duplicate navigation occurs
  7. Verify normal navigation flow continues correctly
  • Verified no JS console errors

Offline tests

  1. Disable network connection
  2. Start Onfido flow
  3. Exit flow
  4. Verify no crash occurs
  5. Re-enable network and repeat

QA Steps

Same as Tests

  • Verify no console errors

@melvin-bot melvin-bot bot requested review from flaviadefaria and hungvu193 and removed request for a team April 17, 2026 08:29
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Apr 17, 2026

@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot removed the request for review from a team April 17, 2026 08:29
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi @pranjal2410719, thanks for your interest in contributing to Expensify!

This PR has been automatically closed because it doesn't appear to meet our contribution requirements:

  • You are not a member of the Expensify GitHub organization
  • No linked GitHub issue was found in the PR description where you are listed as an assignee
  • No linked GitHub PR was found in the PR description where you are the author or a reviewer

If you'd like to contribute, please make sure to:

  1. Find an open issue you'd like to work on
  2. Get assigned to the issue by following our contribution process
  3. Link the issue in your PR description using the format: $ https://github.com/Expensify/App/issues/<issueID>

Please review our contributing guidelines for more details.

If you believe this was closed in error, please reach out in the #expensify-open-source Slack channel.

@github-actions github-actions bot closed this Apr 17, 2026
@github-actions github-actions bot locked as spam and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant