@@ -588,6 +588,9 @@ class LayoutAndSurfaceFields {
588588 }
589589 LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields ();
590590
591+ /** Only do a maximum of 6 repeated layouts. After that quit */
592+ private int mLayoutRepeatCount ;
593+
591594 private final class AnimationRunnable implements Runnable {
592595 @ Override
593596 public void run () {
@@ -1897,7 +1900,7 @@ boolean updateWallpaperOffsetLocked(WindowState wallpaperWin, int dw, int dh,
18971900 rawChanged = true ;
18981901 }
18991902
1900- if (rawChanged && (wallpaperWin .getAttrs () .privateFlags &
1903+ if (rawChanged && (wallpaperWin .mAttrs .privateFlags &
19011904 WindowManager .LayoutParams .PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS ) != 0 ) {
19021905 try {
19031906 if (DEBUG_WALLPAPER ) Slog .v (TAG , "Report new wp offset "
@@ -2296,7 +2299,7 @@ public void removeWindowLocked(Session session, WindowState win) {
22962299 if (wasVisible ) {
22972300
22982301 int transit = WindowManagerPolicy .TRANSIT_EXIT ;
2299- if (win .getAttrs () .type == TYPE_APPLICATION_STARTING ) {
2302+ if (win .mAttrs .type == TYPE_APPLICATION_STARTING ) {
23002303 transit = WindowManagerPolicy .TRANSIT_PREVIEW_DONE ;
23012304 }
23022305 // Try starting an animation.
@@ -2761,7 +2764,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27612764 // Try starting an animation; if there isn't one, we
27622765 // can destroy the surface right away.
27632766 int transit = WindowManagerPolicy .TRANSIT_EXIT ;
2764- if (win .getAttrs () .type == TYPE_APPLICATION_STARTING ) {
2767+ if (win .mAttrs .type == TYPE_APPLICATION_STARTING ) {
27652768 transit = WindowManagerPolicy .TRANSIT_PREVIEW_DONE ;
27662769 }
27672770 if (!win .mSurfacePendingDestroy && win .isWinVisibleLw () &&
@@ -7459,10 +7462,25 @@ private final void performLayoutAndPlaceSurfacesLocked() {
74597462
74607463 } else {
74617464 mInLayout = false ;
7462- if (mLayoutNeeded ) {
7465+ }
7466+
7467+ if (mLayoutNeeded ) {
7468+ if (++mLayoutRepeatCount < 6 ) {
74637469 requestTraversalLocked ();
7470+ } else {
7471+ Slog .e (TAG , "Performed 6 layouts in a row. Skipping" );
7472+ mLayoutRepeatCount = 0 ;
74647473 }
7474+ } else {
7475+ mLayoutRepeatCount = 0 ;
7476+ }
7477+
7478+ if (mAnimator .mAnimating ) {
7479+ // Do this even if requestTraversalLocked was called above so we get a frame drawn
7480+ // at the proper time as well as the one drawn early.
7481+ scheduleAnimationLocked ();
74657482 }
7483+
74667484 if (mWindowsChanged && !mWindowChangeListeners .isEmpty ()) {
74677485 mH .removeMessages (H .REPORT_WINDOWS_CHANGE );
74687486 mH .sendMessage (mH .obtainMessage (H .REPORT_WINDOWS_CHANGE ));
@@ -8192,13 +8210,15 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
81928210 mLayoutNeeded = true ;
81938211 }
81948212 }
8213+
81958214 if ((mPendingLayoutChanges & WindowManagerPolicy .FINISH_LAYOUT_REDO_CONFIG ) != 0 ) {
81968215 if (DEBUG_LAYOUT ) Slog .v (TAG , "Computing new config from layout" );
81978216 if (updateOrientationFromAppTokensLocked (true )) {
81988217 mLayoutNeeded = true ;
81998218 mH .sendEmptyMessage (H .SEND_NEW_CONFIGURATION );
82008219 }
82018220 }
8221+
82028222 if ((mPendingLayoutChanges & WindowManagerPolicy .FINISH_LAYOUT_REDO_LAYOUT ) != 0 ) {
82038223 mLayoutNeeded = true ;
82048224 }
@@ -8409,8 +8429,6 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84098429 }
84108430 }
84118431
8412- boolean needRelayout = false ;
8413-
84148432 if (!mAnimator .mAnimating && mAppTransitionRunning ) {
84158433 // We have finished the animation of an app transition. To do
84168434 // this, we have delayed a lot of operations like showing and
@@ -8419,7 +8437,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84198437 // be out of sync with it. So here we will just rebuild the
84208438 // entire app window list. Fun!
84218439 mAppTransitionRunning = false ;
8422- needRelayout = true ;
8440+ mLayoutNeeded = true ;
84238441 rebuildAppWindowListLocked ();
84248442 assignLayersLocked ();
84258443 // Clear information about apps that were moving.
@@ -8430,19 +8448,10 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84308448 mH .sendEmptyMessage (H .REPORT_LOSING_FOCUS );
84318449 }
84328450 if (wallpaperDestroyed ) {
8433- needRelayout = adjustWallpaperWindowsLocked () != 0 ;
8434- }
8435- if ((mPendingLayoutChanges & (
8436- WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER |
8437- ADJUST_WALLPAPER_LAYERS_CHANGED |
8438- WindowManagerPolicy .FINISH_LAYOUT_REDO_CONFIG |
8439- WindowManagerPolicy .FINISH_LAYOUT_REDO_LAYOUT )) != 0 ) {
8440- needRelayout = true ;
8451+ mLayoutNeeded |= adjustWallpaperWindowsLocked () != 0 ;
84418452 }
8442- if (needRelayout ) {
8443- requestTraversalLocked ();
8444- } else if (mAnimator .mAnimating ) {
8445- scheduleAnimationLocked ();
8453+ if (mPendingLayoutChanges != 0 ) {
8454+ mLayoutNeeded = true ;
84468455 }
84478456
84488457 // Finally update all input windows now that the window changes have stabilized.
@@ -8485,7 +8494,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84858494 }
84868495 }
84878496
8488- if (mInnerFields .mOrientationChangeComplete && !needRelayout &&
8497+ if (mInnerFields .mOrientationChangeComplete && !mLayoutNeeded &&
84898498 !mInnerFields .mUpdateRotation ) {
84908499 checkDrawnWindowsLocked ();
84918500 }
0 commit comments