From b9c44aae79938ff7f979254945cc1f66c09bf5cd Mon Sep 17 00:00:00 2001 From: chaviw Date: Wed, 19 Feb 2020 16:00:08 -0800 Subject: [PATCH] Fix Display SurfaceControl leak The DisplayContent was merging its transaction into the RootWindowContainer's pendingTransaction. However, that transaction is never applied so it was stuck in that transaction forever. There's no need to merge to parent transaction when removing since calling getPendingTransaction will already return the DisplayContent's transaction. Also added a forced Transaction.apply() when removing the DisplayContent since there's a chance it may no be reachable when performSurfacePlacement is called to apply all transactions. Test: EncodeVirtualDisplayWithCompositionTest#testVirtualDisplayRecycles No longer leaks SurfaceControls Fixes: 149526716 Change-Id: I14aa5b2e0e14d75fb0285a1b7a511235064f621c (cherry picked from commit 93938469fc7866cc199f136657b575d1d7c5dae1) --- .../core/java/com/android/server/wm/DisplayContent.java | 3 +++ .../core/java/com/android/server/wm/WindowContainer.java | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 0029dc8c3c25d..17696e6ec38e7 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -2718,6 +2718,9 @@ class DisplayContent extends WindowContainer extends ConfigurationContainer< if (mSurfaceControl != null) { getPendingTransaction().remove(mSurfaceControl); - - // Merge to parent transaction to ensure the transactions on this WindowContainer are - // applied in native even if WindowContainer is removed. - if (mParent != null) { - mParent.getPendingTransaction().merge(getPendingTransaction()); - } - setSurfaceControl(null); mLastSurfacePosition.set(0, 0); scheduleAnimation();