Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf8cbbe7 authored by Craig Mautner's avatar Craig Mautner
Browse files

Skip layout if performShow fails.

In cases where a Surface does not go from hidden to shown, do not set
the perform layout flag. This keeps us out of repeated passes through
the layout code.

Fixes bug 6222487.

Change-Id: I22601bef5733d2f996a8cbdd50d6b89517bc3122
parent 2cd24ecf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -336,6 +336,10 @@ class AppWindowToken extends WindowToken {
        }

        service.mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            service.debugLayoutRepeats("AppWindowToken");
        }

        clearAnimation();
        animating = false;
        if (animLayerAdjustment != 0) {
+31 −4
Original line number Diff line number Diff line
@@ -67,24 +67,32 @@ public class WindowAnimator {
        final int NAT = mService.mAppTokens.size();
        for (i=0; i<NAT; i++) {
            final AppWindowToken appToken = mService.mAppTokens.get(i);
            final boolean wasAnimating = appToken.animation != null;
            final boolean wasAnimating = appToken.animation != null
                    && appToken.animation != WindowManagerService.sDummyAnimation;
            if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
                mAnimating = true;
            } else if (wasAnimating) {
                // stopped animating, do one more pass through the layout
                mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                    mService.debugLayoutRepeats("appToken " + appToken + " done");
                }
            }
        }
        
        final int NEAT = mService.mExitingAppTokens.size();
        for (i=0; i<NEAT; i++) {
            final AppWindowToken appToken = mService.mExitingAppTokens.get(i);
            final boolean wasAnimating = appToken.animation != null;
            final boolean wasAnimating = appToken.animation != null
                    && appToken.animation != WindowManagerService.sDummyAnimation;
            if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
                mAnimating = true;
            } else if (wasAnimating) {
                // stopped animating, do one more pass through the layout
                mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                    mService.debugLayoutRepeats("exiting appToken " + appToken + " done");
                }
            }
        }

@@ -119,6 +127,9 @@ public class WindowAnimator {
                                "First draw done in potential wallpaper target " + w);
                        mService.mInnerFields.mWallpaperMayChange = true;
                        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 1");
                        }
                    }
                }

@@ -192,6 +203,9 @@ public class WindowAnimator {
                if (wasAnimating && !w.mAnimating && mService.mWallpaperTarget == w) {
                    mService.mInnerFields.mWallpaperMayChange = true;
                    mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                        mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2");
                    }
                }

                if (mPolicy.doesForceHide(w, attrs)) {
@@ -201,6 +215,9 @@ public class WindowAnimator {
                                + w);
                        mService.mInnerFields.mWallpaperForceHidingChanged = true;
                        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3");
                        }
                        mService.mFocusMayChange = true;
                    } else if (w.isReadyForDisplay() && w.mAnimation == null) {
                        mForceHiding = true;
@@ -239,6 +256,9 @@ public class WindowAnimator {
                            & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                        mService.mInnerFields.mWallpaperMayChange = true;
                        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4");
                        }
                    }
                }
            }
@@ -286,8 +306,12 @@ public class WindowAnimator {
                    }
                }
            } else if (w.mReadyToShow) {
                w.performShowLocked();
                if (w.performShowLocked()) {
                    mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                        mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5");
                    }
                }
            }
            if (atoken != null && atoken.thumbnail != null) {
                if (atoken.thumbnailTransactionSeq != mTransactionSequence) {
@@ -331,6 +355,9 @@ public class WindowAnimator {
                            + " drawn=" + wtoken.numDrawnWindows);
                    wtoken.allDrawn = true;
                    mPendingLayoutChanges |= PhoneWindowManager.FINISH_LAYOUT_REDO_ANIM;
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                        mService.debugLayoutRepeats("testTokenMayBeDrawnLocked");
                    }

                    // We can now show all of the drawn windows!
                    if (!mService.mOpeningApps.contains(wtoken)) {
+20 −1
Original line number Diff line number Diff line
@@ -170,10 +170,12 @@ public class WindowManagerService extends IWindowManager.Stub
    static final boolean DEBUG_SCREEN_ON = false;
    static final boolean DEBUG_SCREENSHOT = false;
    static final boolean DEBUG_BOOT = false;
    static final boolean DEBUG_LAYOUT_REPEATS = false;
    static final boolean SHOW_SURFACE_ALLOC = false;
    static final boolean SHOW_TRANSACTIONS = false;
    static final boolean SHOW_LIGHT_TRANSACTIONS = false || SHOW_TRANSACTIONS;
    static final boolean HIDE_STACK_CRAWLS = true;
    static final int LAYOUT_REPEAT_THRESHOLD = 4;

    static final boolean PROFILE_ORIENTATION = false;
    static final boolean localLOGV = DEBUG;
@@ -3326,6 +3328,7 @@ public class WindowManagerService extends IWindowManager.Stub
        return wtoken.appWindowToken;
    }

    @Override
    public void addWindowToken(IBinder token, int type) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "addWindowToken()")) {
@@ -8378,6 +8381,8 @@ public class WindowManagerService extends IWindowManager.Stub
                    break;
                }

                if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("On entry to LockedInner");

                if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
                    if ((adjustWallpaperWindowsLocked()&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
                        assignLayersLocked();
@@ -8407,6 +8412,7 @@ public class WindowManagerService extends IWindowManager.Stub
                // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think
                // it is animating.
                mPendingLayoutChanges = 0;
                if (DEBUG_LAYOUT_REPEATS)  debugLayoutRepeats("loop number " + mLayoutRepeatCount);
                mPolicy.beginAnimationLw(dw, dh);
                for (i = mWindows.size() - 1; i >= 0; i--) {
                    WindowState w = mWindows.get(i);
@@ -8415,7 +8421,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                }
                mPendingLayoutChanges |= mPolicy.finishAnimationLw();
                
                if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishAnimationLw");
            } while (mPendingLayoutChanges != 0);

            final boolean someoneLosingFocus = !mLosingFocus.isEmpty();
@@ -8460,6 +8466,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // to go.
        if (mAppTransitionReady) {
            mPendingLayoutChanges |= handleAppTransitionReadyLocked();
            if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after handleAppTransitionReadyLocked");
        }

        mInnerFields.mAdjResult = 0;
@@ -8472,6 +8479,7 @@ public class WindowManagerService extends IWindowManager.Stub
            // be out of sync with it.  So here we will just rebuild the
            // entire app window list.  Fun!
            mPendingLayoutChanges |= handleAnimatingStoppedAndTransitionLocked();
            if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after handleAnimStopAndXitionLock");
        }

        if (mInnerFields.mWallpaperForceHidingChanged && mPendingLayoutChanges == 0 &&
@@ -8483,12 +8491,15 @@ public class WindowManagerService extends IWindowManager.Stub
            // hard -- the wallpaper now needs to be shown behind
            // something that was hidden.
            mPendingLayoutChanges |= animateAwayWallpaperLocked();
            if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after animateAwayWallpaperLocked");
        }

        mPendingLayoutChanges |= testWallpaperAndBackgroundLocked();
        if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after testWallpaperAndBackgroundLocked");

        if (mLayoutNeeded) {
            mPendingLayoutChanges |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT;
            if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded");
        }

        final int N = mWindows.size();
@@ -8502,6 +8513,7 @@ public class WindowManagerService extends IWindowManager.Stub
        // associated with exiting/removed apps
        mAnimator.animate();
        mPendingLayoutChanges |= mAnimator.mPendingLayoutChanges;
        if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after animate()");

        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
@@ -9757,4 +9769,11 @@ public class WindowManagerService extends IWindowManager.Stub
    public interface OnHardKeyboardStatusChangeListener {
        public void onHardKeyboardStatusChange(boolean available, boolean enabled);
    }
    
    void debugLayoutRepeats(final String msg) {
        if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) {
            Slog.v(TAG, "Layouts looping: " + msg);
            Slog.v(TAG, "mPendingLayoutChanges = 0x" + Integer.toHexString(mPendingLayoutChanges));
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -989,6 +989,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                }
                mAppToken.updateReportedVisibilityLocked();
            }
        } else {
            return false;
        }
        return true;
    }
@@ -1128,6 +1130,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {

        finishExit();
        mService.mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) mService.debugLayoutRepeats("WindowState");

        if (mAppToken != null) {
            mAppToken.updateReportedVisibilityLocked();