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
This commit is contained in:
wilsonshih
2022-02-17 16:37:28 +08:00
committed by Wei Sheng Shih
parent 6bc26a0374
commit 0c6bc130f6

View File

@@ -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