diff options
author | 2025-01-31 15:13:18 -0800 | |
---|---|---|
committer | 2025-01-31 15:13:18 -0800 | |
commit | ec28bbfb6a315a5122a4ae770c5bd06f0ba8bb9c (patch) | |
tree | aabf3f35d26a8105b3d72cb2500d75292e4cb90b | |
parent | 1e73f1ce73b93237b78fd05878697272b10a2bb6 (diff) | |
parent | ce298705433b7fccbd084c4fbb3aadc911b6a1eb (diff) |
Merge "Make sure Bitmap for PiP overlay being recycled" into main
-rw-r--r-- | libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipContentOverlay.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipContentOverlay.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipContentOverlay.java index 62ca5c687a2a..9f0c7322dfff 100644 --- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipContentOverlay.java +++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/pip/PipContentOverlay.java @@ -169,6 +169,8 @@ public abstract class PipContentOverlay { // The maximum size for app icon in pixel. private static final int MAX_APP_ICON_SIZE_DP = 72; + private static final long RECYCLE_BITMAP_TIMEOUT_MILLIS = 2_000; + private final Context mContext; private final int mAppIconSizePx; /** @@ -231,6 +233,12 @@ public abstract class PipContentOverlay { tx.setAlpha(mLeash, 0f); tx.reparent(mLeash, parentLeash); tx.apply(); + + // Recycle the mBitmap as a last resort. + if (mContext.getMainThreadHandler() != null) { + mContext.getMainThreadHandler().postDelayed( + this::safeRecycle, RECYCLE_BITMAP_TIMEOUT_MILLIS); + } } @Override @@ -256,6 +264,10 @@ public abstract class PipContentOverlay { @Override public void detach(SurfaceControl.Transaction tx) { super.detach(tx); + safeRecycle(); + } + + private void safeRecycle() { if (mBitmap != null && !mBitmap.isRecycled()) { mBitmap.recycle(); } |