diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index c2c8d63af7e60..ee33541d9f40a 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -184,7 +184,9 @@ public class InsetsSourceConsumer { if (oldLeash == null || newLeash == null || !oldLeash.isSameSurface(newLeash)) { applyHiddenToControl(); } - if (!requestedVisible && !mIsAnimationPending) { + + // Remove the surface that owned by last control when it lost. + if (!requestedVisible && !mIsAnimationPending && lastControl == null) { removeSurface(); } }