Skip to content

Commit bb1449b

Browse files
author
Craig Mautner
committed
Reset layout needed at each animation step.
The member variable WindowAnimator.mPendingLayoutChanges was never being reset to 0. Consequently once it was set it was causing endless calls to the layout method. Fixes bug 6208114, 6220403, 6219546. Fixed NPE in RecentsPanelView. Change-Id: Ie529b8f31e535543cb5ae0af9447146306b14eeb
1 parent 764983d commit bb1449b

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,11 @@ public void onTasksLoaded(ArrayList<TaskDescription> tasks) {
615615
if (!mFirstScreenful && tasks.size() == 0) {
616616
return;
617617
}
618-
mNumItemsWaitingForThumbnailsAndIcons =
619-
mFirstScreenful ? tasks.size() : mRecentTaskDescriptions.size();
618+
mNumItemsWaitingForThumbnailsAndIcons = mFirstScreenful
619+
? tasks.size() : mRecentTaskDescriptions == null
620+
? 0 : mRecentTaskDescriptions.size();
620621
if (mRecentTaskDescriptions == null) {
621-
mRecentTaskDescriptions = new ArrayList(tasks);
622+
mRecentTaskDescriptions = new ArrayList<TaskDescription>(tasks);
622623
} else {
623624
mRecentTaskDescriptions.addAll(tasks);
624625
}

services/java/com/android/server/wm/WindowAnimator.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* on behalf of WindowManagerService.
2424
*/
2525
public class WindowAnimator {
26-
private static final String TAG = "WindowAnimations";
26+
private static final String TAG = "WindowAnimator";
2727

2828
final WindowManagerService mService;
2929
final Context mContext;
@@ -67,8 +67,24 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
6767
final int NAT = mService.mAppTokens.size();
6868
for (i=0; i<NAT; i++) {
6969
final AppWindowToken appToken = mService.mAppTokens.get(i);
70+
final boolean wasAnimating = appToken.animation != null;
7071
if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
7172
mAnimating = true;
73+
} else if (wasAnimating) {
74+
// stopped animating, do one more pass through the layout
75+
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
76+
}
77+
}
78+
79+
final int NEAT = mService.mExitingAppTokens.size();
80+
for (i=0; i<NEAT; i++) {
81+
final AppWindowToken appToken = mService.mExitingAppTokens.get(i);
82+
final boolean wasAnimating = appToken.animation != null;
83+
if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
84+
mAnimating = true;
85+
} else if (wasAnimating) {
86+
// stopped animating, do one more pass through the layout
87+
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
7288
}
7389
}
7490

@@ -517,6 +533,7 @@ public void prepareSurfaceLocked(final WindowState w, final boolean recoveringMe
517533
}
518534

519535
void animate() {
536+
mPendingLayoutChanges = 0;
520537
mCurrentTime = SystemClock.uptimeMillis();
521538

522539
// Update animations of all applications, including those

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)