fix(navigation): prevent ArrayIndexOutOfBoundsException on back navigation (COLUMBA-BF) - #1040
Open
sentry[bot] wants to merge 1 commit into
Open
fix(navigation): prevent ArrayIndexOutOfBoundsException on back navigation (COLUMBA-BF)#1040sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
…ation (COLUMBA-BF)
Contributor
Greptile SummaryPrevents a back-navigation crash by keeping root-tab back callbacks stable during navigation gestures.
Confidence Score: 5/5The PR appears safe to merge, with the back handler remaining scoped to the active root destination. The changed handler removes unstable route-based enablement while preserving root-only double-back-to-exit behavior through each destination composable's lifecycle. Important Files Changed
Reviews (1): Last reviewed commit: "fix(navigation): prevent ArrayIndexOutOf..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses an
ArrayIndexOutOfBoundsExceptionthat occurred when navigating back to a root tab (e.g.,/chats) from another screen.Root Cause:
The
DoubleBackToExitHandlercomposable usedBackHandler(enabled = currentRoute == route). During a back navigation gesture,currentRoutewould update before the gesture completed, causing theenabledstate to flip. This led to theBackHandlerbeing re-registered or unregistered while theOnBackPressedDispatcher's callbacks array was being iterated, resulting in a concurrent modification and theArrayIndexOutOfBoundsException.Solution:
route: Stringparameter fromDoubleBackToExitHandler.enabled = currentRoute == routecondition from theBackHandlerwithinDoubleBackToExitHandler.DoubleBackToExitHandlerto no longer pass therouteargument.By removing the explicit
enabledcondition, theBackHandlernow relies on Navigation Compose's lifecycle management. SinceDoubleBackToExitHandleris called within eachcomposable(route) { ... }block, theBackHandleris automatically tied to theNavBackStackEntry's lifecycle, ensuring it is only active when the corresponding screen is on the back stack. This prevents the mid-gesture state changes that caused the crash.Fixes COLUMBA-BF