From 4234e6cea8c9aa34a778d21a35576e7a8d40f9a5 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 22 Feb 2022 22:23:48 +0100 Subject: [PATCH] Get rid of double measure We first need to dispatch insets, then we can measure so we don't need to immediately measure again. Fixes: 210881360 Bug: 190379081 Test: Presubmit, Boots Change-Id: Id40a083dd2e122ca71a96213e94b5bbbb45d596d --- core/java/android/view/ViewRootImpl.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 844403298cc97..f7539d53da176 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2721,6 +2721,10 @@ public final class ViewRootImpl implements ViewParent, // Execute enqueued actions on every traversal in case a detached view enqueued an action getRunQueue().executeActions(mAttachInfo.mHandler); + if (mApplyInsetsRequested && !(mWillMove || mWillResize)) { + dispatchApplyInsets(host); + } + boolean layoutRequested = mLayoutRequested && (!mStopped || mReportNextDraw); if (layoutRequested) { @@ -2785,18 +2789,6 @@ public final class ViewRootImpl implements ViewParent, } } - if (mApplyInsetsRequested && !(mWillMove || mWillResize)) { - dispatchApplyInsets(host); - if (mLayoutRequested) { - // Short-circuit catching a new layout request here, so - // we don't need to go through two layout passes when things - // change due to fitting system windows, which can happen a lot. - windowSizeMayChange |= measureHierarchy(host, lp, - mView.getContext().getResources(), - desiredWindowWidth, desiredWindowHeight); - } - } - if (layoutRequested) { // Clear this now, so that if anything requests a layout in the // rest of this function we will catch it and re-run a full