From 0c6bc130f64db7cdd2a886ab5928225295135e66 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Thu, 17 Feb 2022 16:37:28 +0800 Subject: [PATCH] Release the surface control view host when addWindow fail. The graphic memory which allocate for animatable icon cannot be released from #onDetachedFromWindow if that SurfaceView never been added to a window, release the host if addWindow failed. Test: manual test, force #addWindow always fail and cold start an app with animatable icon, verify no SurfaceView object left in surface. Bug: 218264452 Change-Id: I024c64ce134235e487b6ab7cf33ba9fdf4079046 Merged-In: I024c64ce134235e487b6ab7cf33ba9fdf4079046 --- .../wm/shell/startingsurface/StartingSurfaceDrawer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java index 34426991a459b..61cbf6e3c93cf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java @@ -364,6 +364,12 @@ public class StartingSurfaceDrawer { final StartingWindowRecord record = mStartingWindowRecords.get(taskId); final SplashScreenView contentView = viewSupplier.get(); record.mBGColor = contentView.getInitBackgroundColor(); + } else { + // release the icon view host + final SplashScreenView contentView = viewSupplier.get(); + if (contentView.getSurfaceHost() != null) { + SplashScreenView.releaseIconHost(contentView.getSurfaceHost()); + } } } catch (RuntimeException e) { // don't crash if something else bad happens, for example a