Fix: Nav3 "Key used multiple times" crash (b/516312097)#3014
Merged
Conversation
…ability Use capturing lambdas in the regression test so each buildScene() call produces NavEntry instances with distinct content lambda references. The old empty-lambda form was compiled to a shared singleton, causing both entries to share one content reference and the identity-based equals to return true even before the contentKey fix, making the test vacuous.
…2097) Convert NavSuiteScene and NavUpBarScene from private data class to internal class, replacing the auto-generated data class equals/hashCode (which delegated to the wrapped Scene and therefore to NavEntry.content lambda identity) with explicit key-based equality: two wrappers are equal iff scene::class and scene.key match. Adds navUpBarSceneDecoratorStrategy() as a public factory for the ShowUpBar path that does not need a SharedTransitionScope, enabling plain-JUnit testing. NavUpBarSceneEqualityTest verifies the fix RED/GREEN through that factory; NavSuiteScene is covered by the identical equals/hashCode logic (SharedTransitionScope makes direct construction in a plain JVM test impractical, as noted in its class comment).
navUpBarSceneDecoratorStrategy has no production caller: it exists purely so NavUpBarSceneEqualityTest in :app can reach the internal NavUpBarScene equality logic. Annotate it @VisibleForTesting and replace the KDoc that falsely claimed "callers that only need the up-bar decoration can use it" with an honest description of its role as a test seam.
…fix (b/516312097)
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.
Production crash java.lang.IllegalArgumentException: Key HomeKey was used multiple times, thrown by SaveableStateProvider when NavDisplay composes two live entries that share a contentKey. This is the Nav3 framework bug b/516312097.
AI Summary:
Root cause
Two independent contributors, both fixed here:
Changes