From 6ed2c410d7fafb2e46f2dd677b5146878f0fc613 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Tue, 9 Jun 2020 11:30:45 -0700 Subject: [PATCH] Remove DynamicAnimation when it ends. It holds strong reference to the animation target, which is the key in WeakHashMap so we need to make sure we clean them up when they are not needed anymore. Bug: 149918957 Test: Animation of bubbles look fine. This path to GC root is removed. Change-Id: Ibdf24de730602e87b57790bb270fa7ac3524e7fe --- .../com/android/systemui/util/animation/PhysicsAnimator.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt index 318a6d727e5c9..016f4de724b65 100644 --- a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt +++ b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt @@ -644,6 +644,12 @@ class PhysicsAnimator private constructor (target: T) { it.onInternalAnimationEnd( property, canceled, value, velocity, anim is FlingAnimation) } + if (springAnimations[property] == anim) { + springAnimations.remove(property) + } + if (flingAnimations[property] == anim) { + flingAnimations.remove(property) + } } return anim }