Repository navigation
fix(android): don't reuse a CustomTransition's animator between runs - #13
Merged
Merged
Conversation
setAnimatorsTarget added its listeners to the AnimatorSet given to the constructor and returned that same instance on every run. Nothing removes them, so each navigation left a CustomAnimatorListener holding the animated view, plus the Transition$2 and DisappearListener that androidx adds, on an animator the transition keeps alive. Every page that ever animated was kept alive with it (PageLayout, collectionviews, map views). Clone the AnimatorSet for each run so the listeners go away with it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What is the current behavior?
CustomTransition.setAnimatorsTargetadds its listeners to theAnimatorSetgiven to the constructor and returns that same instance on every run. Nothing removes them, so each navigation leaves, on an animator the transition keeps alive:CustomAnimatorListenerholding the animated view,Transition$2andVisibility$DisappearListenerandroidx adds (they reach the transition clone and itsmEndValues, i.e. the views).Every page that ever animated stays alive:
PageLayout, its collectionviews, map views, with the native memory they hold. Heap dump after 11 open/close cycles: 48CustomAnimatorListenerpinning 15 distinctPageLayouts, oneAnimatorSetwith 10 of each listener.What is the new behavior?
setAnimatorsTargetclones theAnimatorSetfor each run, so the listeners go away with the clone.Measured on an app (emulator, forced GC after each cycle, QuickJS-ng runtime, 4 to 5 cycles each; V8 showed the same page retention before the fix):
PageLayoutinstances left in a heap dump: 15 to 0; heroTextureMapViews: 4 to 0.Verification
./gradlew assembleReleaseonui-mobile-base/androidbuilds.portal:to this package, numbers above. No unit test: there is no Java test setup for the widgets.CustomTransitionusers (custom, flip, shared element). The animator is now one clone peronAppear/onDisappearcall;resetOnTransitionEndclones that same per-run instance. A quick visual pass on those is worth doing.Notes
🤖 Generated with Claude Code