Skip to content

[MS-1376] Add a guard against a race condition in MatcherFragment#1604

Merged
BurningAXE merged 1 commit intomainfrom
MS-1376-Crash-on-matcher-finishing-while-on-exit-screen
Mar 5, 2026
Merged

[MS-1376] Add a guard against a race condition in MatcherFragment#1604
BurningAXE merged 1 commit intomainfrom
MS-1376-Crash-on-matcher-finishing-while-on-exit-screen

Conversation

@BurningAXE
Copy link
Contributor

@BurningAXE BurningAXE commented Mar 3, 2026

JIRA ticket
Will be released in: 2026.2.0

Root cause analysis (for bugfixes only)

First known affected version: a very old one!?

  • If matcher finishes while user has navigated to exit screen, exit result is delivered first and then the matcher result gets forwarded to the Orchestrator which expects AppResult and crashes

Notable changes

  • Adds a guard to the matchResponse observer - if current destination is not MatcherFragment anymore - drop the result as the user has already navigated away

Testing guidance

  • Trigger and identification (preferably with a large pool and/or just-in-time CoSync so you have time to react)
  • Proceed through the steps
  • When you reach the matching step press back to go to the exit screen
  • Wait some time to give the matcher time to finish (monitor logcat if device is connected)
  • Select an exit reason and submit
  • App should return a refusal without KABOOM

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

@cla-bot cla-bot bot added the ... label Mar 3, 2026
@BurningAXE BurningAXE requested review from a team, TristramN, alex-vt, alexandr-simprints, Copilot, luhmirin-s, meladRaouf and ybourgery and removed request for a team March 3, 2026 16:33
@BurningAXE BurningAXE marked this pull request as ready for review March 3, 2026 16:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a navigation-state guard in MatchFragment to prevent delivering a match result after the user has navigated away (e.g., to the exit form), avoiding a crash in the Orchestrator caused by an unexpected result type/order.

Changes:

  • Adds a NavController.currentDestination check before calling finishWithResult() for matchResponse.
  • Documents the intent with an inline comment.

Comment on lines 121 to +128
viewModel.matchResponse.observe(
viewLifecycleOwner,
LiveDataEventWithContentObserver {
findNavController().finishWithResult(this, it)
// Guard against delivering the match result after the fragment has already
// been popped (e.g. exit form submitted after match finished in the background).
if (findNavController().currentDestination?.id == R.id.matcherFragment) {
findNavController().finishWithResult(this, it)
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LiveDataEventWithContentObserver calls getContentIfNotHandled() before entering this lambda, so when currentDestination is not matcherFragment the match result will be silently consumed (lost). This can leave the user stuck if they navigate to the exit form and then tap “continue/go back” (no submission): when they return to MatchFragment the match has finished but the result event can no longer be delivered. Consider observing the LiveDataEventWithContent directly and only calling getContentIfNotHandled() after verifying the destination (or otherwise buffering the result until the fragment is current again).

Copilot uses AI. Check for mistakes.
@BurningAXE BurningAXE force-pushed the MS-1376-Crash-on-matcher-finishing-while-on-exit-screen branch from bbb0554 to b729abb Compare March 5, 2026 11:08
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 5, 2026

@BurningAXE BurningAXE merged commit edc52be into main Mar 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants