From 708dbe80902b963388c412f670c56ae00953273a Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Thu, 13 Jul 2023 15:34:07 +0000 Subject: [PATCH] View: Remove tooltip callbacks when detached from window When a View has tooltip text set, every hover event will fire a callback to hide the tooltip after a 15 second timeout. Since the callback holds a reference to the View, it will leak the View for that duration after the Activity is finished or the View is removed. Prevent this temporary leak by removing the tooltip callbacks immediately when the View is detatched from the window. Bug: 281473769 Test: manual, heap dump using Android Studio Change-Id: I9044759be0feaf094aa4c140565dfa015b944bd8 Merged-In: I9044759be0feaf094aa4c140565dfa015b944bd8 --- core/java/android/view/View.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 483c39d98ae16..f50dc8ddd262f 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -21206,6 +21206,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mCurrentAnimation = null; if ((mViewFlags & TOOLTIP) == TOOLTIP) { + removeCallbacks(mTooltipInfo.mShowTooltipRunnable); + removeCallbacks(mTooltipInfo.mHideTooltipRunnable); hideTooltip(); }