Commit dce191f1 authored by Pavel Shmakov's avatar Pavel Shmakov Committed by Commit Bot

Fix memory leak in ToolbarProgressBar

This is a follow-up to https://chromium-review.googlesource.com/c/chromium/src/+/1172425

Another memory leak was found in ToolbarProgressBar. It happens due because animations are not cleaned up when activity is destroyed.
The references to animation listeners get stuck in android.animation.AnimationHandler, which is a singleton. From the animation listeners the chain of references leads all the way up to ChromeTabbedActivity instances.

So this leak happens when user closes Chrome while the page is loading, and then the system kills the activity. It's easily reproducible with "Don't keep activities" option.

Bug: 872661
Change-Id: I6eebc11a575d45c899f37be5ca7a6862923f0ee5
Reviewed-on: https://chromium-review.googlesource.com/1175795Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Pavel Shmakov <pshmakov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583320}
parent 4746202f
......@@ -262,6 +262,13 @@ public class ToolbarProgressBar extends ClipDrawableProgressBar {
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
mIsAttachedToWindow = false;
if (mProgressThrottle != null) {
mProgressThrottle.setTimeListener(null);
mProgressThrottle.cancel();
}
mSmoothProgressAnimator.setTimeListener(null);
mSmoothProgressAnimator.cancel();
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment