fix(android): prevent memory leak from reused CustomTransition animat… · NativeScript/NativeScript@056a03e · GitHub
Skip to content

Commit 056a03e

Browse files
authored
fix(android): prevent memory leak from reused CustomTransition animator (#11270)
CustomTransition exposed a single shared AnimatorSet (this.animatorSet) and returned it from onAppear/onDisappear. androidx clones the transition per run but shares this field, and the framework attaches its own end listeners (Visibility$OverlayListener, etc.) to the returned AnimatorSet. For zero-duration ("none") navigation those listeners are not removed, so a reused CustomTransition accumulated one stale listener per navigation, each retaining the previous fragment and its page view. With animations disabled this leaked the entire navigation history; the leaked Java views in turn kept their linked JS objects alive forever. Run on a per-invocation clone of the AnimatorSet so framework listeners land on a throwaway instance and the shared template stays clean, and release the animated view (mView) when the animation ends. [skip ci]
1 parent b69aedb commit 056a03e

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/CustomTransition.java

Lines changed: 26 additions & 9 deletions

0 commit comments

Comments
 (0)