From bd015de12e84a23aa6a3951001f568e0ee8b926d Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Thu, 5 Nov 2026 11:21:20 +0100 Subject: [PATCH] fix(android): don't reuse a CustomTransition's animator between runs 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 --- .../org/nativescript/widgets/CustomTransition.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/CustomTransition.java b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/CustomTransition.java index 004a2e76ca..2390bd1351 100644 --- a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/CustomTransition.java +++ b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/CustomTransition.java @@ -57,9 +57,11 @@ public String getTransitionName() { return this.transitionName; } - private Animator setAnimatorsTarget(AnimatorSet animatorSet, final View view) { + private Animator setAnimatorsTarget(AnimatorSet source, final View view) { + // A fresh animator per run: the shared one kept, run after run, the listeners holding the animated view + // and the transition clones, so every page that ever animated stayed alive. + AnimatorSet animatorSet = source.clone(); ArrayList animatorsList = animatorSet.getChildAnimations(); - boolean resetOnTransitionEnd = this.resetOnTransitionEnd; for (int i = 0; i < animatorsList.size(); i++) { animatorsList.get(i).setTarget(view); @@ -67,7 +69,7 @@ private Animator setAnimatorsTarget(AnimatorSet animatorSet, final View view) { // Reset animation to its initial state to prevent mirrorered effect if (this.resetOnTransitionEnd) { - this.immediateAnimatorSet = this.animatorSet.clone(); + this.immediateAnimatorSet = animatorSet.clone(); } // Switching to hardware layer during transition to improve animation performance @@ -75,7 +77,7 @@ private Animator setAnimatorsTarget(AnimatorSet animatorSet, final View view) { animatorSet.addListener(listener); this.addListener(new CustomTransitionListenerAdapter(this)); - return this.animatorSet; + return animatorSet; } private class ReverseInterpolator implements Interpolator {