diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index 8e50fed7f3923..f6df9f49d93f3 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -179,7 +179,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(); } }