From 019e08fdbb8c92625d8818551b1ba124c028cebc Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 8 Jul 2020 12:44:47 -0700 Subject: [PATCH] ViewRootImpl: Call surface destroy callback after layout pass If a requestLayout happens on a child view after the measure pass, before the layout pass then the child view will not layout. This can happen if a view calls requestLayout during measure or during SurfaceView surface destroyed callback. This fix addresses the second scenario by moving the callback to after the layout pass. Bug: 159183008 Test: Repro steps in bug Test: go/wm-smoke Change-Id: Ie2794a3751c99cabf6e07445c91159e35eeb1729 --- core/java/android/view/ViewRootImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 896a2de8b1354..2fa8c4573c470 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2724,7 +2724,6 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mThreadedRenderer.isEnabled()) { mAttachInfo.mThreadedRenderer.destroy(); } - notifySurfaceDestroyed(); } else if ((surfaceReplaced || surfaceSizeChanged || windowRelayoutWasForced || colorModeChanged) && mSurfaceHolder == null @@ -2955,6 +2954,10 @@ public final class ViewRootImpl implements ViewParent, } } + if (surfaceDestroyed) { + notifySurfaceDestroyed(); + } + if (triggerGlobalLayoutListener) { mAttachInfo.mRecomputeGlobalAttributes = false; mAttachInfo.mTreeObserver.dispatchOnGlobalLayout();