feat(android): skip transition graph for non-animated navigation#11271
Open
edusperoni wants to merge 1 commit into
Open
feat(android): skip transition graph for non-animated navigation#11271edusperoni wants to merge 1 commit into
edusperoni wants to merge 1 commit into
Conversation
Regular (non-nested) non-animated navigation created a zero-duration NoTransition/CustomTransition on every navigation purely to receive a transition-end callback that drives navigation completion. That graph is leak-prone: androidx attaches end listeners to the (shared) AnimatorSet which are not removed for a zero-duration run, so each navigation left a stale listener retaining the previous fragment and page. Skip setting up any fragment transitions for this case. Completion is already driven by FragmentCallbacksImplementation.onResume -> setCurrent when nothing is animating, so no transition-end callback is needed. The nested-first-navigation path is left untouched (it is a one-off per frame, not per navigation, so it does not accumulate).
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx test apps-automated -c=android |
❌ Failed | 34m 50s | View ↗ |
nx run-many --target=test --configuration=ci --... |
✅ Succeeded | <1s | View ↗ |
💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.
☁️ Nx Cloud last updated this comment at 2026-06-18 18:21:52 UTC
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.

PR Checklist
What is the current behavior?
On Android, every non-animated page navigation sets up a zero-duration
NoTransition/CustomTransitiongraph. Its only purpose is to receive a transition-end callback that drives navigation completion — there is no actual animation to run. Besides being wasteful, this graph is the source of a memory leak: androidx attaches end listeners to the (shared)AnimatorSetthat are never removed for a zero-duration run, so each navigation leaves a stale listener retaining the previous fragment and its page.What is the new behavior?
Regular (non-nested) non-animated navigation no longer creates any fragment transitions. Navigation completion is already driven by
FragmentCallbacksImplementation.onResume -> frame.setCurrentwhenever nothing is animating, so the zero-duration transition was unnecessary. The nested-first-navigation path is left untouched (it runs once per nested frame, not per navigation, so it does not accumulate). This removes the leak at its source for the common case and avoids building/tearing down a transition + dummy animator on every navigation.Related / split PRs
This is the root-cause half of the fix and is intentionally split from #11270 because it is more behaviorally risky: it makes the existing
onResumefallback the primary completion path for non-animated navigation, which is worth extra scrutiny across edge cases (clearHistory, modal frames, rapid/queued navigations, app suspend/resume mid-navigation).#11270 is the lower-risk native fix (run each
CustomTransitionon a per-invocationAnimatorSetclone so framework listeners can't accumulate) and stands on its own. The two are complementary: #11270 protects all remainingCustomTransitionusers (animated/custom transitions and the nested path); this PR additionally avoids creating the graph at all for the common non-animated case. #11270 can ship independently of this one.