Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bfce2cc authored by Doris Liu's avatar Doris Liu
Browse files

Fix AVD memory leak

The memory leak was caused by a lingering internal listener
that held a global ref to the AVD java object when the AVD is
infinite. As a result, the native VectorDrawable Tree can
not be destroyed, and therefore leak bitmaps.

This memory leak is fixed by removing all the internal listeners
for all the unfinished AVDs when the animation context is
destroyed.

BUG: 37518414
Test: follow steps in comment #1 of the bug, and inspect memory heap.

Change-Id: Ibbd1547a083b83d0cebd8e304d9b01abda4950ef
parent 29db4b35
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -208,8 +208,15 @@ public:

    void detachAnimators() {
        // Remove animators from the list and post a delayed message in future to end the animator
        // For infinite animators, remove the listener so we no longer hold a global ref to the AVD
        // java object, and therefore the AVD objects in both native and Java can be properly
        // released.
        for (auto& anim : mRunningVDAnimators) {
            detachVectorDrawableAnimator(anim.get());
            anim->clearOneShotListener();
        }
        for (auto& anim : mPausedVDAnimators) {
            anim->clearOneShotListener();
        }
        mRunningVDAnimators.clear();
        mPausedVDAnimators.clear();