From 4a088432b6026735dbe8ebf8f204229496f09f0f Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 19 Mar 2018 15:08:13 -0700 Subject: [PATCH] Reset dummy stack view tasks after computing transition into Recents - Also clear up references from the app transition spec future to the parent implementation, which can also leak memory. Bug: 73961798 Test: Enter recents, ensure that dummy stack view holds no task refs Change-Id: I0c466350c1c1dd490f8776ca23f13de0d698e060 --- .../shared/recents/view/AppTransitionAnimationSpecsFuture.java | 4 ++++ .../SystemUI/src/com/android/systemui/recents/RecentsImpl.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/AppTransitionAnimationSpecsFuture.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/AppTransitionAnimationSpecsFuture.java index 85d362a7a767..c227feec75b6 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/AppTransitionAnimationSpecsFuture.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/AppTransitionAnimationSpecsFuture.java @@ -49,6 +49,10 @@ public abstract class AppTransitionAnimationSpecsFuture { mHandler.post(mComposeTask); } List specs = mComposeTask.get(); + // Clear reference to the compose task this future holds onto the reference to it's + // implementation (which can leak references to the bitmap it creates for the + // transition) + mComposeTask = null; if (specs == null) { return null; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index ac26f68bacf7..19da3dba17e8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -276,6 +276,9 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener } }; + // Used to reset the dummy stack view + private final TaskStack mEmptyTaskStack = new TaskStack(); + public RecentsImpl(Context context) { mContext = context; mHandler = new Handler(); @@ -1108,6 +1111,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener } }); EventBus.getDefault().send(hideMenuEvent); + + // Once we have launched the activity, reset the dummy stack view tasks so we don't hold + // onto references to the same tasks consumed by the activity + mDummyStackView.setTasks(mEmptyTaskStack, false /* notifyStackChanges */); } /**** OnAnimationFinishedListener Implementation ****/ -- 2.11.0