基础知识
Stop入口
在这个流程期间判断加入Stopping列表的ActivityRecord是否正在执行动画,正在执行退出动画的页面不能执行stop流程。 如何判断ActivityRecord正在执行动画
private void processStoppingAndFinishingActivities(ActivityRecord launchedActivity,
boolean processPausingActivities, String reason) {
ArrayList<ActivityRecord> readyToStopActivities = null;
for (int i = mStoppingActivities.size() - 1; i >= 0; --i) {
final ActivityRecord s = mStoppingActivities.get(i);
final boolean animating = s.isAnimating(TRANSITION | PARENTS,
ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_RECENTS)
|| s.inTransition();
ProtoLog.v(WM_DEBUG_STATES, "Stopping %s: nowVisible=%b animating=%b "
+ "finishing=%s", s, s.nowVisible, animating, s.finishing);
if (!animating || mService.mShuttingDown) {
if (!processPausingActivities && s.isState(PAUSING)) {
removeIdleTimeoutForActivity(launchedActivity);
scheduleIdleTimeout(launchedActivity);
continue;
}
ProtoLog.v(WM_DEBUG_STATES, "Ready to stop: %s", s);
if (readyToStopActivities == null) {
readyToStopActivities = new ArrayList<>();
}
readyToStopActivities.add(s);
mStoppingActivities.remove(i);
}
}
final int numReadyStops = readyToStopActivities == null ? 0 : readyToStopActivities.size();
for (int i = 0; i < numReadyStops; i++) {
final ActivityRecord r = readyToStopActivities.get(i);
if (r.isInHistory()) {
if (r.finishing) {
r.destroyIfPossible(reason);
} else {
r.stopIfPossible();
}
}
}
........
}
处理Stopping列表来自以下两条线:
执行IDLE_NOW_MSG消息
case IDLE_NOW_MSG: {
if (DEBUG_IDLE) Slog.d(TAG_IDLE, "handleMessage: IDLE_NOW_MSG: r=" + msg.obj);
activityIdleFromMessage((ActivityRecord) msg.obj, false );
} break;
......
private void activityIdleFromMessage(ActivityRecord idleActivity, boolean fromTimeout) {
activityIdleInternal(idleActivity, fromTimeout,
fromTimeout , null );
}
app端回调activityIdle
@Override
public void activityIdle(IBinder token, Configuration config, boolean stopProfiling) {
final long origId = Binder.clearCallingIdentity();
try {
synchronized (mGlobalLock) {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "activityIdle");
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
if (r == null) {
return;
}
mTaskSupervisor.activityIdleInternal(r, false ,
false , config);
if (stopProfiling && r.hasProcess()) {
r.app.clearProfilerIfNeeded();
}
}
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
Binder.restoreCallingIdentity(origId);
}
}
执行PROCESS_STOPPING_AND_FINISHING_MSG消息
case PROCESS_STOPPING_AND_FINISHING_MSG: {
processStoppingAndFinishingActivities(null ,
false , "transit");
} break;
执行IDLE_TIMEOUT_MSG超时消息
case IDLE_TIMEOUT_MSG: {
if (DEBUG_IDLE) Slog.d(TAG_IDLE,
"handleMessage: IDLE_TIMEOUT_MSG: r=" + msg.obj);
activityIdleFromMessage((ActivityRecord) msg.obj, true );
} break;
发送相关消息
display线程的消息队列里,没有IDLE_NOW_MSG消息时才会去发送消息;
final void scheduleIdle() {
if (!mHandler.hasMessages(IDLE_NOW_MSG)) {
mHandler.sendEmptyMessage(IDLE_NOW_MSG);
}
}
IDLE_NOW_MSG-直接发送
上一个页面完成pause后触发system server端的makeInvisible,将当前页面加入stoppping列表并尝试发送idle消息。
void addToStopping(boolean scheduleIdle, boolean idleDelayed, String reason) {
.......
if (scheduleIdle || forceIdle) {
ProtoLog.v(WM_DEBUG_STATES,
"Scheduling idle now: forceIdle=%b immediate=%b", forceIdle, !idleDelayed);
if (!idleDelayed) {
mTaskSupervisor.scheduleIdle();
} else {
mTaskSupervisor.scheduleIdleTimeout(this);
}
} else {
rootTask.checkReadyForSleep();
}
}
IDLE_NOW_MSG-条件发送
在scheduleProcessStoppingAndFinishingActivitiesIfNeeded方法中满足以下条件也可尝试发送:
- mStoppingActivities 存在待stop的Activity
- 所有resume的Activity均处于idle状态
void scheduleProcessStoppingAndFinishingActivitiesIfNeeded() {
if (mStoppingActivities.isEmpty() && mFinishingActivities.isEmpty()) {
return;
}
if (mRootWindowContainer.allResumedActivitiesIdle()) {
scheduleIdle();
return;
}
if (!mHandler.hasMessages(PROCESS_STOPPING_AND_FINISHING_MSG)
&& mRootWindowContainer.allResumedActivitiesVisible()) {
mHandler.sendEmptyMessage(PROCESS_STOPPING_AND_FINISHING_MSG);
}
}
发送PROCESS_STOPPING_AND_FINISHING_MSG消息
如上,scheduleProcessStoppingAndFinishingActivitiesIfNeeded 中如果不满足idle条件,但是所有resume页面处于可见状态;可以发送PROCESS_STOPPING_AND_FINISHING_MSG消息
发送IDLE_TIMEOUT_MSG超时消息
在system server端页面resume的时候去发送10s的延时消息,防止app主线程生命周期方法中操作耗时导致不能及时idle或visible。
private static final int IDLE_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;
void scheduleIdleTimeout(ActivityRecord next) {
if (DEBUG_IDLE) Slog.d(TAG_IDLE, "scheduleIdleTimeout: Callers=" + Debug.getCallers(4));
Message msg = mHandler.obtainMessage(IDLE_TIMEOUT_MSG, next);
mHandler.sendMessageDelayed(msg, IDLE_TIMEOUT);
}
相关条件成立
1. Stopping列表不为空
void addToStopping(boolean scheduleIdle, boolean idleDelayed, String reason) {
if (!mTaskSupervisor.mStoppingActivities.contains(this)) {
EventLogTags.writeWmAddToStopping(mUserId, System.identityHashCode(this),
shortComponentName, reason);
mTaskSupervisor.mStoppingActivities.add(this);
}
......
}
2-1. Resume的Activity处于idle状态
void activityIdleInternal(ActivityRecord r, boolean fromTimeout,
boolean processPausingActivities, Configuration config) {
if (DEBUG_ALL) Slog.v(TAG, "Activity idle: " + r);
if (r != null) {
if (DEBUG_IDLE) Slog.d(TAG_IDLE, "activityIdleInternal: Callers="
+ Debug.getCallers(4));
mHandler.removeMessages(IDLE_TIMEOUT_MSG, r);
r.finishLaunchTickingLocked();
if (fromTimeout) {
reportActivityLaunched(fromTimeout, r, INVALID_DELAY, -1 );
}
if (config != null) {
r.setLastReportedGlobalConfiguration(config);
}
r.idle = true;
if ((mService.isBooting() && mRootWindowContainer.allResumedActivitiesIdle())
|| fromTimeout) {
checkFinishBootingLocked();
}
r.mRelaunchReason = RELAUNCH_REASON_NONE;
}
......
}
boolean allResumedActivitiesIdle() {
for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {
final DisplayContent display = getChildAt(displayNdx);
if (display.isSleeping()) {
continue;
}
final Task rootTask = display.getFocusedRootTask();
if (rootTask == null || !rootTask.hasActivity()) {
continue;
}
final ActivityRecord resumedActivity = rootTask.getTopResumedActivity();
if (resumedActivity == null || !resumedActivity.idle) {
ProtoLog.d(WM_DEBUG_STATES, "allResumedActivitiesIdle: rootTask=%d %s "
+ "not idle", rootTask.getRootTaskId(), resumedActivity);
return false;
}
}
mService.endLaunchPowerMode(ActivityTaskManagerService.POWER_MODE_REASON_START_ACTIVITY);
return true;
}
2-2. 或Resume的Activity窗口Visible
void onWindowsVisible() {
if (DEBUG_VISIBILITY) Slog.v(TAG_WM, "Reporting visible in " + token);
mTaskSupervisor.stopWaitingForActivityVisible(this);
if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsVisibleLocked(): " + this);
if (!nowVisible) {
nowVisible = true;
launching = false;
lastVisibleTime = SystemClock.uptimeMillis();
mAtmService.scheduleAppGcsLocked();
mTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded();
if (mImeInsetsFrozenUntilStartInput && getWindow(
win -> WindowManager.LayoutParams.mayUseInputMethod(win.mAttrs.flags))
== null) {
mImeInsetsFrozenUntilStartInput = false;
}
}
}
boolean allResumedActivitiesVisible() {
boolean[] foundResumed = {false};
final boolean foundInvisibleResumedActivity = forAllRootTasks(rootTask -> {
final ActivityRecord r = rootTask.getTopResumedActivity();
if (r != null) {
if (!r.nowVisible) {
return true;
}
foundResumed[0] = true;
}
return false;
});
if (foundInvisibleResumedActivity) {
return false;
}
return foundResumed[0];
}
2-3. 或已经到了10s超时时间
动画结束
如何判断ActivityRecord正在执行动画
private OnAnimationFinishedCallback getFinishedCallback(
@Nullable OnAnimationFinishedCallback staticAnimationFinishedCallback) {
return (type, anim) -> {
synchronized (mService.mGlobalLock) {
final SurfaceAnimator target = mService.mAnimationTransferMap.remove(anim);
if (target != null) {
target.mInnerAnimationFinishedCallback.onAnimationFinished(type, anim);
return;
}
if (anim != mAnimation) {
return;
}
final Runnable resetAndInvokeFinish = () -> {
if (anim != mAnimation) {
return;
}
final OnAnimationFinishedCallback animationFinishCallback =
mSurfaceAnimationFinishedCallback;
reset(mAnimatable.getSyncTransaction(), true );
;
if (staticAnimationFinishedCallback != null) {
staticAnimationFinishedCallback.onAnimationFinished(type, anim);
}
if (animationFinishCallback != null) {
animationFinishCallback.onAnimationFinished(type, anim);
}
};
if (!(mAnimatable.shouldDeferAnimationFinish(resetAndInvokeFinish)
|| anim.shouldDeferAnimationFinish(resetAndInvokeFinish))) {
resetAndInvokeFinish.run();
}
mAnimationFinished = true;
}
};
}
常见场景
同个App进入新的页面
Prepare动画
Breakpoint reached
at com.android.server.wm.AppTransition.prepareAppTransition(AppTransition.java:1596)
at com.android.server.wm.DisplayContent.prepareAppTransition(DisplayContent.java:5605)
at com.android.server.wm.DisplayContent.prepareAppTransition(DisplayContent.java:5596)
at com.android.server.wm.TaskFragment.resumeTopActivity(TaskFragment.java:1455)
at com.android.server.wm.Task.resumeTopActivityInnerLocked(Task.java:5602)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5530)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2417)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2403)
at com.android.server.wm.TaskFragment.completePause(TaskFragment.java:1908)
at com.android.server.wm.ActivityRecord.activityPaused(ActivityRecord.java:6673)
at com.android.server.wm.ActivityClientController.activityPaused(ActivityClientController.java:191)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:582)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3110_20 -> add mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.ActivityRecord.setVisibility(ActivityRecord.java:5650)
at com.android.server.wm.ActivityRecord.setVisibility(ActivityRecord.java:5500)
at com.android.server.wm.ActivityRecord.makeInvisible(ActivityRecord.java:6403)
at com.android.server.wm.EnsureActivitiesVisibleHelper.setActivityVisibilityState(EnsureActivitiesVisibleHelper.java:239)
at com.android.server.wm.EnsureActivitiesVisibleHelper.process(EnsureActivitiesVisibleHelper.java:143)
at com.android.server.wm.TaskFragment.updateActivityVisibilities(TaskFragment.java:1153)
at com.android.server.wm.Task.lambda$ensureActivitiesVisible$20(Task.java:5426)
at com.android.server.wm.Task$$ExternalSyntheticLambda23.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.Task.ensureActivitiesVisible(Task.java:5425)
at com.android.server.wm.DisplayContent.lambda$ensureActivitiesVisible$45$com-android-server-wm-DisplayContent(DisplayContent.java:6468)
at com.android.server.wm.DisplayContent$$ExternalSyntheticLambda38.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.DisplayContent.ensureActivitiesVisible(DisplayContent.java:6463)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1911)
at com.android.server.wm.RootWindowContainer.ensureVisibilityAndConfig(RootWindowContainer.java:1780)
at com.android.server.wm.ActivityTaskSupervisor.realStartActivityLocked(ActivityTaskSupervisor.java:883)
at com.android.server.wm.ActivityTaskSupervisor.startSpecificActivity(ActivityTaskSupervisor.java:1136)
at com.android.server.wm.TaskFragment.resumeTopActivity(TaskFragment.java:1643)
at com.android.server.wm.Task.resumeTopActivityInnerLocked(Task.java:5602)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5530)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2417)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2403)
at com.android.server.wm.TaskFragment.completePause(TaskFragment.java:1908)
at com.android.server.wm.ActivityRecord.activityPaused(ActivityRecord.java:6673)
at com.android.server.wm.ActivityClientController.activityPaused(ActivityClientController.java:191)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:582)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3110_20 -> add mClosingApps
addToStopping并发送idle消息
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleIdle(ActivityTaskSupervisor.java:2305)
at com.android.server.wm.ActivityRecord.addToStopping(ActivityRecord.java:6858)
at com.android.server.wm.ActivityRecord.makeInvisible(ActivityRecord.java:6417)
at com.android.server.wm.EnsureActivitiesVisibleHelper.setActivityVisibilityState(EnsureActivitiesVisibleHelper.java:239)
at com.android.server.wm.EnsureActivitiesVisibleHelper.process(EnsureActivitiesVisibleHelper.java:143)
at com.android.server.wm.TaskFragment.updateActivityVisibilities(TaskFragment.java:1153)
at com.android.server.wm.Task.lambda$ensureActivitiesVisible$20(Task.java:5426)
at com.android.server.wm.Task$$ExternalSyntheticLambda23.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.Task.ensureActivitiesVisible(Task.java:5425)
at com.android.server.wm.DisplayContent.lambda$ensureActivitiesVisible$45$com-android-server-wm-DisplayContent(DisplayContent.java:6468)
at com.android.server.wm.DisplayContent$$ExternalSyntheticLambda38.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.DisplayContent.ensureActivitiesVisible(DisplayContent.java:6463)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1911)
at com.android.server.wm.RootWindowContainer.ensureVisibilityAndConfig(RootWindowContainer.java:1780)
at com.android.server.wm.ActivityTaskSupervisor.realStartActivityLocked(ActivityTaskSupervisor.java:883)
at com.android.server.wm.ActivityTaskSupervisor.startSpecificActivity(ActivityTaskSupervisor.java:1136)
at com.android.server.wm.TaskFragment.resumeTopActivity(TaskFragment.java:1643)
at com.android.server.wm.Task.resumeTopActivityInnerLocked(Task.java:5602)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5530)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2417)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2403)
at com.android.server.wm.TaskFragment.completePause(TaskFragment.java:1908)
at com.android.server.wm.ActivityRecord.activityPaused(ActivityRecord.java:6673)
at com.android.server.wm.ActivityClientController.activityPaused(ActivityClientController.java:191)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:582)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3110_20 -> send IDLE_NOW_MSG
执行IDLE_NOW_MSG消息
因为当前执行了上面Prepare动画,所以isAnimating返回true,无法正常执行Stop流程
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.activityIdleFromMessage(ActivityTaskSupervisor.java:2672)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessageInner(ActivityTaskSupervisor.java:2705)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessage(ActivityTaskSupervisor.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.display ->com.android.settings/.MainSettings -> animating= true
开始执行动画
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.startAnimation(SurfaceAnimator.java:172)
at com.android.server.wm.WindowContainer.startAnimation(WindowContainer.java:2861)
at com.android.server.wm.WindowContainer$AnimationRunnerBuilder.lambda$build$4$com-android-server-wm-WindowContainer$AnimationRunnerBuilder(WindowContainer.java:4192)
at com.android.server.wm.WindowContainer$AnimationRunnerBuilder$$ExternalSyntheticLambda4.startAnimation(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowContainer.applyAnimationUnchecked(WindowContainer.java:3322)
at com.android.server.wm.WindowContainer.applyAnimation(WindowContainer.java:3015)
at com.android.server.wm.ActivityRecord.applyAnimation(ActivityRecord.java:5683)
at com.android.server.wm.AppTransitionController.applyAnimations(AppTransitionController.java:865)
at com.android.server.wm.AppTransitionController.applyAnimations(AppTransitionController.java:1072)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:293)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
com.android.settings/.MainSettings
Breakpoint reached
at com.android.server.wm.AppTransition.goodToGo(AppTransition.java:391)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:307)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> clear mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:318)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> clear mClosingApps
设置resume页面为idle状态
app回调activityIdle,设置当前resume页面为idle状态并尝试stop;因为已经开始执行动画,isAnimating仍然为true,不能进行stop流程
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityClientController.activityIdle(ActivityClientController.java:150)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:558)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3110_16 ->com.android.settings/.MainSettings -> animating= true
当前resume页面动画结束&窗口可见
因为上面的mStoppingActivities不为空 & allResumedActivitiesIdle & 消息队列没有IDLE_NOW_MSG消息,所以发送消息成功
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleIdle(ActivityTaskSupervisor.java:2305)
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2411)
at com.android.server.wm.ActivityRecord.onWindowsVisible(ActivityRecord.java:7160)
at com.android.server.wm.ActivityRecord.updateReportedVisibilityLocked(ActivityRecord.java:7276)
at com.android.server.wm.WindowManagerService$4.onAppTransitionFinishedLocked(WindowManagerService.java:1298)
at com.android.server.wm.AppTransition.notifyAppTransitionFinishedLocked(AppTransition.java:500)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8218)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:133)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.AnimatingActivityRegistry.endDeferringFinished(AnimatingActivityRegistry.java:104)
at com.android.server.wm.AnimatingActivityRegistry.notifyAboutToFinish(AnimatingActivityRegistry.java:77)
at com.android.server.wm.ActivityRecord.shouldDeferAnimationFinish(ActivityRecord.java:7921)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:141)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.LocalAnimationAdapter.lambda$startAnimation$0$com-android-server-wm-LocalAnimationAdapter(LocalAnimationAdapter.java:67)
at com.android.server.wm.LocalAnimationAdapter$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:-1)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> com.android.settings/.SubSettings -> true
android.anim -> send IDLE_NOW_MSG
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleIdle(ActivityTaskSupervisor.java:2305)
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2411)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8223)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:133)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.AnimatingActivityRegistry.endDeferringFinished(AnimatingActivityRegistry.java:104)
at com.android.server.wm.AnimatingActivityRegistry.notifyAboutToFinish(AnimatingActivityRegistry.java:77)
at com.android.server.wm.ActivityRecord.shouldDeferAnimationFinish(ActivityRecord.java:7921)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:141)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.LocalAnimationAdapter.lambda$startAnimation$0$com-android-server-wm-LocalAnimationAdapter(LocalAnimationAdapter.java:67)
at com.android.server.wm.LocalAnimationAdapter$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:-1)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim
android.anim -> com.android.settings/.SubSettings -> true
上个退出页面动画结束
回调ActivityRecord的 onAnimationFinished,因为上面已经存在IDLE_NOW_MSG消息,所以不必重复发送
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.reset(SurfaceAnimator.java:402)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:131)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.LocalAnimationAdapter.lambda$startAnimation$0$com-android-server-wm-LocalAnimationAdapter(LocalAnimationAdapter.java:67)
at com.android.server.wm.LocalAnimationAdapter$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:-1)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
com.android.settings/.MainSettings
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleIdle(ActivityTaskSupervisor.java:2305)
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2411)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8223)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:133)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.LocalAnimationAdapter.lambda$startAnimation$0$com-android-server-wm-LocalAnimationAdapter(LocalAnimationAdapter.java:67)
at com.android.server.wm.LocalAnimationAdapter$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:-1)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> com.android.settings/.MainSettings -> false
执行idle消息
因为上个退出页面动画结束,所以可以执行Stop流程了
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.activityIdleFromMessage(ActivityTaskSupervisor.java:2672)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessageInner(ActivityTaskSupervisor.java:2705)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessage(ActivityTaskSupervisor.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.display ->com.android.settings/.MainSettings -> animating= false
从桌面进入App
跟上面场景相同的不再列举堆栈
Prepare动画(同)
addToStopping并发送idle消息(同)
开始执行动画
大致与上面场景相同,这里针对的是Task的动画
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.startAnimation(SurfaceAnimator.java:172)
at com.android.server.wm.WindowContainer.startAnimation(WindowContainer.java:2861)
at com.android.server.wm.WindowContainer$AnimationRunnerBuilder.lambda$build$4$com-android-server-wm-WindowContainer$AnimationRunnerBuilder(WindowContainer.java:4192)
at com.android.server.wm.WindowContainer$AnimationRunnerBuilder$$ExternalSyntheticLambda4.startAnimation(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowContainer.applyAnimationUnchecked(WindowContainer.java:3322)
at com.android.server.wm.Task.applyAnimationUnchecked(Task.java:3864)
at com.android.server.wm.WindowContainer.applyAnimation(WindowContainer.java:3015)
at com.android.server.wm.AppTransitionController.applyAnimations(AppTransitionController.java:865)
at com.android.server.wm.AppTransitionController.applyAnimations(AppTransitionController.java:1072)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:293)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Task{2aa5333 #7 type=home ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}
Breakpoint reached
at com.android.server.wm.AppTransition.goodToGo(AppTransition.java:391)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:307)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> clear mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:318)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer$Traverser.run(WindowSurfacePlacer.java:79)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.anim -> clear mClosingApps
执行IDLE_NOW_MSG消息
因为当前执行了上面Start动画,所以isAnimating返回true,无法正常执行Stop流程
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.activityIdleFromMessage(ActivityTaskSupervisor.java:2672)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessageInner(ActivityTaskSupervisor.java:2705)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessage(ActivityTaskSupervisor.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.display ->com.miui.home/.launcher.Launcher -> animating= true
上个退出页面(Launcher)动画结束
- 不满足allResumedActivitiesIdle条件,无法发送_IDLE_NOW_MSG_消息
- 不满足allResumedActivitiesVisible,无法发送_PROCESS_STOPPING_AND_FINISHING_MSG_消息
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.reset(SurfaceAnimator.java:402)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:131)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RemoteAnimationController.onAnimationFinished(RemoteAnimationController.java:299)
at com.android.server.wm.RemoteAnimationController.-$$Nest$monAnimationFinished(RemoteAnimationController.java:-1)
at com.android.server.wm.RemoteAnimationController$FinishedCallback.onAnimationFinished(RemoteAnimationController.java:443)
at android.view.IRemoteAnimationFinishedCallback$Stub.onTransact(IRemoteAnimationFinishedCallback.java:89)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
com.miui.home/.launcher.Launcher
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2414)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8223)
at com.android.server.wm.WindowContainer.doAnimationFinished(WindowContainer.java:3509)
at com.android.server.wm.WindowContainer.onAnimationFinished(WindowContainer.java:3524)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:133)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RemoteAnimationController.onAnimationFinished(RemoteAnimationController.java:299)
at com.android.server.wm.RemoteAnimationController.-$$Nest$monAnimationFinished(RemoteAnimationController.java:-1)
at com.android.server.wm.RemoteAnimationController$FinishedCallback.onAnimationFinished(RemoteAnimationController.java:443)
at android.view.IRemoteAnimationFinishedCallback$Stub.onTransact(IRemoteAnimationFinishedCallback.java:89)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
当前resume页面动画结束&窗口可见
这里的线程是binder线程,不是anim 动画结束时无法发送消息,窗口可见时发送_PROCESS_STOPPING_AND_FINISHING_MSG_消息
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2414)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8223)
at com.android.server.wm.WindowContainer.doAnimationFinished(WindowContainer.java:3509)
at com.android.server.wm.WindowContainer.onAnimationFinished(WindowContainer.java:3524)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:133)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RemoteAnimationController.onAnimationFinished(RemoteAnimationController.java:299)
at com.android.server.wm.RemoteAnimationController.-$$Nest$monAnimationFinished(RemoteAnimationController.java:-1)
at com.android.server.wm.RemoteAnimationController$FinishedCallback.onAnimationFinished(RemoteAnimationController.java:443)
at android.view.IRemoteAnimationFinishedCallback$Stub.onTransact(IRemoteAnimationFinishedCallback.java:89)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2414)
at com.android.server.wm.ActivityRecord.onWindowsVisible(ActivityRecord.java:7160)
at com.android.server.wm.ActivityRecord.updateReportedVisibilityLocked(ActivityRecord.java:7276)
at com.android.server.wm.WindowStateAnimator.onAnimationFinished(WindowStateAnimator.java:207)
at com.android.server.wm.WindowState.onAnimationFinished(WindowState.java:5669)
at com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.cancelAnimation(SurfaceAnimator.java:371)
at com.android.server.wm.SurfaceAnimator.cancelAnimation(SurfaceAnimator.java:267)
at com.android.server.wm.WindowContainer.cancelAnimation(WindowContainer.java:2886)
at com.android.server.wm.WindowState.lambda$removeIfPossible$3(WindowState.java:2656)
at com.android.server.wm.WindowState$$ExternalSyntheticLambda0.apply(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowState.applyInOrderWithImeWindows(WindowState.java:5253)
at com.android.server.wm.WindowState.forAllWindows(WindowState.java:5097)
at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:1720)
at com.android.server.wm.WindowState.removeIfPossible(WindowState.java:2654)
at com.android.server.wm.WindowState.removeIfPossible(WindowState.java:2640)
at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2289)
at com.android.server.wm.Session.remove(Session.java:233)
at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:694)
at com.android.server.wm.Session.onTransact(Session.java:185)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1249)
Thread[binder:3224_20,5,main] -> Send PROCESS_STOPPING_AND_FINISHING_MSG
执行_PROCESS_STOPPING_AND_FINISHING_MSG_消息
因为上个退出页面动画结束,所以可以执行Stop流程了
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.-$$Nest$mprocessStoppingAndFinishingActivities(ActivityTaskSupervisor.java:-1)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessageInner(ActivityTaskSupervisor.java:2727)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessage(ActivityTaskSupervisor.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.display ->com.miui.home/.launcher.Launcher -> animating= false
设置resume页面为idle状态
app回调activityIdle,设置当前resume页面为idle状态;因为stoppping列表已经为空了
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityClientController.activityIdle(ActivityClientController.java:150)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:558)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3110_16 ->com.android.settings/.MainSettings -> animating= true
从App返回桌面
开始执行动画
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.startAnimation(SurfaceAnimator.java:172)
at com.android.server.wm.WindowContainer.startAnimation(WindowContainer.java:2861)
at com.android.server.wm.WindowContainer.startAnimation(WindowContainer.java:2868)
at com.android.server.wm.RecentsAnimationController.addAnimation(RecentsAnimationController.java:609)
at com.android.server.wm.RecentsAnimationController.initialize(RecentsAnimationController.java:545)
at com.android.server.wm.WindowManagerService.initializeRecentsAnimation(WindowManagerService.java:3340)
at com.android.server.wm.RecentsAnimation.startRecentsActivity(RecentsAnimation.java:265)
at com.android.server.wm.RecentsAnimation.startRecentsActivity(RecentsAnimation.java:175)
at com.android.server.wm.ActivityTaskManagerService.startRecentsActivity(ActivityTaskManagerService.java:1838)
at android.app.IActivityTaskManager$Stub.onTransact(IActivityTaskManager.java:1399)
at com.android.server.wm.ActivityTaskManagerService.onTransact(ActivityTaskManagerService.java:5514)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
Task{80249ba #178 type=standard A=10071:com.miui.gallery.home U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
以下这一列操作:两个页面动画结束,窗口可见、addToStoppping等都是在recent动画执行结束后同步进行的
上个退出页面Task动画结束
Task动画,RecentsAnimation.onAnimationFinished触发
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.reset(SurfaceAnimator.java:402)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:131)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RecentsAnimationController$TaskAnimationAdapter.onRemove(RecentsAnimationController.java:1407)
at com.android.server.wm.RecentsAnimationController.removeAnimation(RecentsAnimationController.java:635)
at com.android.server.wm.RecentsAnimationController.cleanupAnimation(RecentsAnimationController.java:1076)
at com.android.server.wm.WindowManagerService.cleanupRecentsAnimation(WindowManagerService.java:3366)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:325)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20
Task{80249ba #178 type=standard A=10071:com.miui.gallery.home U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
当前resume桌面动画结束&窗口可见
RecentsAnimation.onAnimationFinished触发 mStopping列表为空,scheduleProcessStoppingAndFinishingActivitiesIfNeeded 中不发送消息
Breakpoint reached
at com.android.server.wm.SurfaceAnimator.reset(SurfaceAnimator.java:402)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:131)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RecentsAnimationController$TaskAnimationAdapter.onRemove(RecentsAnimationController.java:1407)
at com.android.server.wm.RecentsAnimationController.removeAnimation(RecentsAnimationController.java:635)
at com.android.server.wm.RecentsAnimationController.cleanupAnimation(RecentsAnimationController.java:1076)
at com.android.server.wm.WindowManagerService.cleanupRecentsAnimation(WindowManagerService.java:3366)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:325)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
Task{4568f09 #163 type=home I=com.miui.home/.launcher.Launcher U=0 rootTaskId=7 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
Breakpoint reached
at com.android.server.wm.ActivityRecord.onWindowsVisible(ActivityRecord.java:7160)
at com.android.server.wm.ActivityRecord.updateReportedVisibilityLocked(ActivityRecord.java:7276)
at com.android.server.wm.WindowStateAnimator.onAnimationFinished(WindowStateAnimator.java:207)
at com.android.server.wm.WindowState.onAnimationFinished(WindowState.java:5669)
at com.android.server.wm.RecentsAnimationController.lambda$initialize$3(RecentsAnimationController.java:547)
at com.android.server.wm.RecentsAnimationController$$ExternalSyntheticLambda6.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowContainer$ForAllWindowsConsumerWrapper.apply(WindowContainer.java:2733)
at com.android.server.wm.WindowContainer$ForAllWindowsConsumerWrapper.apply(WindowContainer.java:2723)
at com.android.server.wm.WindowState.applyInOrderWithImeWindows(WindowState.java:5253)
at com.android.server.wm.WindowState.forAllWindows(WindowState.java:5097)
at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:1720)
at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:1720)
at com.android.server.wm.WindowContainer.forAllWindows(WindowContainer.java:1737)
at com.android.server.wm.RecentsAnimationController.lambda$initialize$4(RecentsAnimationController.java:546)
at com.android.server.wm.RecentsAnimationController$$ExternalSyntheticLambda9.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:136)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:-1)
at com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$1$com-android-server-wm-SurfaceAnimator(SurfaceAnimator.java:143)
at com.android.server.wm.SurfaceAnimator$$ExternalSyntheticLambda0.onAnimationFinished(D8$$SyntheticClass:-1)
at com.android.server.wm.RecentsAnimationController$TaskAnimationAdapter.onRemove(RecentsAnimationController.java:1407)
at com.android.server.wm.RecentsAnimationController.removeAnimation(RecentsAnimationController.java:635)
at com.android.server.wm.RecentsAnimationController.cleanupAnimation(RecentsAnimationController.java:1076)
at com.android.server.wm.WindowManagerService.cleanupRecentsAnimation(WindowManagerService.java:3366)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:325)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_10 -> com.miui.home/.launcher.Launcher -> false
binder:3237_10 -> mStoppingActivities is null
Prepare动画
RecentsAnimation.onAnimationFinished触发 recent动画结束,添加mNextAppTransitionRequests & mClosingApps
Breakpoint reached
at com.android.server.wm.AppTransition.prepareAppTransition(AppTransition.java:1596)
at com.android.server.wm.DisplayContent.prepareAppTransition(DisplayContent.java:5605)
at com.android.server.wm.DisplayContent.prepareAppTransition(DisplayContent.java:5596)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6207)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6136)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:353)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> add mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.ActivityRecord.setVisibility(ActivityRecord.java:5650)
at com.android.server.wm.ActivityRecord.setVisibility(ActivityRecord.java:5500)
at com.android.server.wm.ActivityRecord.makeInvisible(ActivityRecord.java:6403)
at com.android.server.wm.EnsureActivitiesVisibleHelper.setActivityVisibilityState(EnsureActivitiesVisibleHelper.java:239)
at com.android.server.wm.EnsureActivitiesVisibleHelper.process(EnsureActivitiesVisibleHelper.java:143)
at com.android.server.wm.TaskFragment.updateActivityVisibilities(TaskFragment.java:1153)
at com.android.server.wm.Task.lambda$ensureActivitiesVisible$20(Task.java:5426)
at com.android.server.wm.Task$$ExternalSyntheticLambda23.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.Task.ensureActivitiesVisible(Task.java:5425)
at com.android.server.wm.DisplayContent.lambda$ensureActivitiesVisible$45$com-android-server-wm-DisplayContent(DisplayContent.java:6468)
at com.android.server.wm.DisplayContent$$ExternalSyntheticLambda38.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.DisplayContent.ensureActivitiesVisible(DisplayContent.java:6463)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1911)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1892)
at com.android.server.wm.TaskFragment.completePause(TaskFragment.java:1928)
at com.android.server.wm.TaskFragment.startPausing(TaskFragment.java:1810)
at com.android.server.wm.TaskFragment.startPausing(TaskFragment.java:1678)
at com.android.server.wm.TaskDisplayArea.lambda$pauseBackTasks$7$com-android-server-wm-TaskDisplayArea(TaskDisplayArea.java:1394)
at com.android.server.wm.TaskDisplayArea$$ExternalSyntheticLambda7.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.TaskFragment.forAllLeafTaskFragments(TaskFragment.java:1967)
at com.android.server.wm.TaskDisplayArea.lambda$pauseBackTasks$8$com-android-server-wm-TaskDisplayArea(TaskDisplayArea.java:1387)
at com.android.server.wm.TaskDisplayArea$$ExternalSyntheticLambda5.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.WindowContainer.forAllLeafTasks(WindowContainer.java:2089)
at com.android.server.wm.TaskDisplayArea.pauseBackTasks(TaskDisplayArea.java:1373)
at com.android.server.wm.TaskFragment.resumeTopActivity(TaskFragment.java:1317)
at com.android.server.wm.Task.resumeTopActivityInnerLocked(Task.java:5602)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5530)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5550)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5585)
at com.android.server.wm.ActivityRecord.makeActiveIfNeeded(ActivityRecord.java:6440)
at com.android.server.wm.RootWindowContainer.lambda$resumeFocusedTasksTopActivities$18(RootWindowContainer.java:2447)
at com.android.server.wm.RootWindowContainer$$ExternalSyntheticLambda17.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2425)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2403)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2398)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6235)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6136)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:353)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> add mNextAppTransitionRequests
addToStopping并发送idle消息
RecentsAnimation.onAnimationFinished触发
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleIdle(ActivityTaskSupervisor.java:2305)
at com.android.server.wm.ActivityRecord.addToStopping(ActivityRecord.java:6858)
at com.android.server.wm.ActivityRecord.makeInvisible(ActivityRecord.java:6417)
at com.android.server.wm.EnsureActivitiesVisibleHelper.setActivityVisibilityState(EnsureActivitiesVisibleHelper.java:239)
at com.android.server.wm.EnsureActivitiesVisibleHelper.process(EnsureActivitiesVisibleHelper.java:143)
at com.android.server.wm.TaskFragment.updateActivityVisibilities(TaskFragment.java:1153)
at com.android.server.wm.Task.lambda$ensureActivitiesVisible$20(Task.java:5426)
at com.android.server.wm.Task$$ExternalSyntheticLambda23.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.Task.ensureActivitiesVisible(Task.java:5425)
at com.android.server.wm.DisplayContent.lambda$ensureActivitiesVisible$45$com-android-server-wm-DisplayContent(DisplayContent.java:6468)
at com.android.server.wm.DisplayContent$$ExternalSyntheticLambda38.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.DisplayContent.ensureActivitiesVisible(DisplayContent.java:6463)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1911)
at com.android.server.wm.RootWindowContainer.ensureActivitiesVisible(RootWindowContainer.java:1892)
at com.android.server.wm.TaskFragment.completePause(TaskFragment.java:1928)
at com.android.server.wm.TaskFragment.startPausing(TaskFragment.java:1810)
at com.android.server.wm.TaskFragment.startPausing(TaskFragment.java:1678)
at com.android.server.wm.TaskDisplayArea.lambda$pauseBackTasks$7$com-android-server-wm-TaskDisplayArea(TaskDisplayArea.java:1394)
at com.android.server.wm.TaskDisplayArea$$ExternalSyntheticLambda7.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.TaskFragment.forAllLeafTaskFragments(TaskFragment.java:1967)
at com.android.server.wm.TaskDisplayArea.lambda$pauseBackTasks$8$com-android-server-wm-TaskDisplayArea(TaskDisplayArea.java:1387)
at com.android.server.wm.TaskDisplayArea$$ExternalSyntheticLambda5.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllLeafTasks(Task.java:3590)
at com.android.server.wm.WindowContainer.forAllLeafTasks(WindowContainer.java:2089)
at com.android.server.wm.TaskDisplayArea.pauseBackTasks(TaskDisplayArea.java:1373)
at com.android.server.wm.TaskFragment.resumeTopActivity(TaskFragment.java:1317)
at com.android.server.wm.Task.resumeTopActivityInnerLocked(Task.java:5602)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5530)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5550)
at com.android.server.wm.Task.resumeTopActivityUncheckedLocked(Task.java:5585)
at com.android.server.wm.ActivityRecord.makeActiveIfNeeded(ActivityRecord.java:6440)
at com.android.server.wm.RootWindowContainer.lambda$resumeFocusedTasksTopActivities$18(RootWindowContainer.java:2447)
at com.android.server.wm.RootWindowContainer$$ExternalSyntheticLambda17.accept(D8$$SyntheticClass:-1)
at com.android.server.wm.Task.forAllRootTasks(Task.java:3602)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2124)
at com.android.server.wm.WindowContainer.forAllRootTasks(WindowContainer.java:2117)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2425)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2403)
at com.android.server.wm.RootWindowContainer.resumeFocusedTasksTopActivities(RootWindowContainer.java:2398)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6235)
at com.android.server.wm.Task.moveTaskToFront(Task.java:6136)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:353)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> send IDLE_NOW_MSG
上个退出页面Activity动画结束
RecentsAnimation.onAnimationFinished触发 因为窗口可见,发送PROCESS_STOPPING_AND_FINISHING_MSG消息,并清空mClosingApps&mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.scheduleProcessStoppingAndFinishingActivitiesIfNeeded(ActivityTaskSupervisor.java:2414)
at com.android.server.wm.ActivityRecord.onAnimationFinished(ActivityRecord.java:8223)
at com.android.server.wm.ActivityRecord.postApplyAnimation(ActivityRecord.java:5835)
at com.android.server.wm.ActivityRecord.commitVisibility(ActivityRecord.java:5785)
at com.android.server.wm.ActivityRecord.commitVisibility(ActivityRecord.java:5811)
at com.android.server.wm.AppTransitionController.handleClosingApps(AppTransitionController.java:1194)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:295)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer.continueLayout(WindowSurfacePlacer.java:119)
at com.android.server.wm.ActivityTaskManagerService.continueWindowLayout(ActivityTaskManagerService.java:4695)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:419)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> com.miui.gallery/.activity.HomePageActivity -> true
Thread[binder:3237_1A,5,main] -> Send PROCESS_STOPPING_AND_FINISHING_MSG
Breakpoint reached
at com.android.server.wm.AppTransition.goodToGo(AppTransition.java:391)
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:307)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer.continueLayout(WindowSurfacePlacer.java:119)
at com.android.server.wm.ActivityTaskManagerService.continueWindowLayout(ActivityTaskManagerService.java:4695)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:419)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> clear mNextAppTransitionRequests
Breakpoint reached
at com.android.server.wm.AppTransitionController.handleAppTransitionReady(AppTransitionController.java:318)
at com.android.server.wm.RootWindowContainer.checkAppTransitionReady(RootWindowContainer.java:998)
at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:865)
at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:805)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:199)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:148)
at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:137)
at com.android.server.wm.WindowSurfacePlacer.continueLayout(WindowSurfacePlacer.java:119)
at com.android.server.wm.ActivityTaskManagerService.continueWindowLayout(ActivityTaskManagerService.java:4695)
at com.android.server.wm.RecentsAnimation.lambda$finishAnimation$0$com-android-server-wm-RecentsAnimation(RecentsAnimation.java:419)
at com.android.server.wm.RecentsAnimation$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:-1)
at com.android.server.wm.WindowManagerService.inSurfaceTransaction(WindowManagerService.java:8865)
at com.android.server.wm.RecentsAnimation.finishAnimation(RecentsAnimation.java:320)
at com.android.server.wm.RecentsAnimation.onAnimationFinished(RecentsAnimation.java:438)
at com.android.server.wm.RecentsAnimationController$3.finish(RecentsAnimationController.java:319)
at android.view.IRecentsAnimationController$Stub.onTransact(IRecentsAnimationController.java:299)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
binder:3237_20 -> clear mClosingApps
执行IDLE_NOW_MSG消息
动画结束,执行成功
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.processStoppingAndFinishingActivities(ActivityTaskSupervisor.java:2164)
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.activityIdleFromMessage(ActivityTaskSupervisor.java:2672)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessageInner(ActivityTaskSupervisor.java:2705)
at com.android.server.wm.ActivityTaskSupervisor$ActivityTaskSupervisorHandler.handleMessage(ActivityTaskSupervisor.java:2647)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.os.HandlerThread.run(HandlerThread.java:67)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
android.display ->com.miui.gallery/.activity.HomePageActivity -> animating= false
设置resume页面为idle状态
app回调activityIdle,设置当前resume页面为idle状态;因为stoppping列表已经为空了
Breakpoint reached
at com.android.server.wm.ActivityTaskSupervisor.activityIdleInternal(ActivityTaskSupervisor.java:1519)
at com.android.server.wm.ActivityClientController.activityIdle(ActivityClientController.java:150)
at android.app.IActivityClientController$Stub.onTransact(IActivityClientController.java:558)
at com.android.server.wm.ActivityClientController.onTransact(ActivityClientController.java:131)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
com.miui.gallery/.activity.HomePageActivity
如何分析
方向
同个App切换Stop慢
- 上一个页面得及时完成onPause
- 上一个页面得及时执行完动画
- 下一个页面得及时执行完动画完成窗口可见或者app主线程及时处于idle状态
桌面点击图标桌面Stop慢
- 桌面及时完成onPause
- 桌面及时执行玩Task动画
- 下一个页面得及时执行完动画完成窗口可见或者桌面主线程及时处于idle状态
从App上滑返回桌面Stop慢
Log打开&查看
执行如下命令打开相关的debug 开关:
adb shell am logging enable-text DEBUG_IDLE DEBUG_VISIBILITY
adb shell wm logging enable-text WM_DEBUG_ANIM WM_DEBUG_STATES
查看开关是否顺利打开:
adb shell dumpsys activity logging
adb shell dumpsys window logging
查看log
adb logcat -b all -c
adb logcat -b all | egrep "activityIdleInternal|wm_add_to_stopping|Animation done in|Reporting visible in|wm_stop_activity|Ready to stop"
同个App切换页面
09-23 15:58:35.754 6857 19863 I wm_add_to_stopping: [0,223949794,com.android.settings/.MainSettings,makeInvisible]
09-23 15:58:35.773 6857 6880 I ActivityTaskManager: activityIdleInternal(): r=null, mStartingUsers=[]
09-23 15:58:35.896 6857 19863 D ActivityTaskManager: activityIdleInternal: Callers=com.android.server.wm.ActivityClientController.activityIdle:150 android.app.IActivityClientController$Stub.onTransact:558 com.android.server.wm.ActivityClientController.onTransact:131 android.os.Binder.execTransactInternal:1290
09-23 15:58:35.897 6857 19863 I ActivityTaskManager: activityIdleInternal(): r=ActivityRecord{737204e u0 com.android.settings/.SubSettings} t190}, mStartingUsers=[]
09-23 15:58:36.377 6857 6881 V WindowManager: Animation done in ActivityRecord{d5933e2 u0 com.android.settings/.MainSettings} t190}: reportedVisible=true okToDisplay=true okToAnimate=true startingDisplayed=false
09-23 15:58:36.379 6857 6881 V WindowManager: Animation done in ActivityRecord{737204e u0 com.android.settings/.SubSettings} t190}: reportedVisible=false okToDisplay=true okToAnimate=true startingDisplayed=false
09-23 15:58:36.379 6857 6881 V WindowManager: Reporting visible in Token{2cd4705 ActivityRecord{737204e u0 com.android.settings/.SubSettings} t190}}
09-23 15:58:36.382 6857 6880 V WindowManager: Ready to stop: ActivityRecord{d5933e2 u0 com.android.settings/.MainSettings} t190}
09-23 15:58:36.383 6857 6880 I wm_stop_activity: [0,223949794,com.android.settings/.MainSettings]
09-23 15:58:36.383 6857 6880 I ActivityTaskManager: activityIdleInternal(): r=null, mStartingUsers=[]
09-23 15:58:36.393 6857 6880 I ActivityTaskManager: activityIdleInternal(): r=null, mStartingUsers=[]
桌面点击App图标
09-23 16:11:45.009 5050 6955 I wm_add_to_stopping: [0,5778117,com.miui.home/.launcher.Launcher,makeInvisible]
09-23 16:11:45.044 5050 5074 I ActivityTaskManager: activityIdleInternal(): r=null, mStartingUsers=[]
09-23 16:11:45.631 5050 5066 V WindowManager: Animation done in ActivityRecord{582ac5 u0 com.miui.home/.launcher.Launcher} t2}: reportedVisible=true okToDisplay=true okToAnimate=true startingDisplayed=false
09-23 16:11:45.632 5050 5066 V WindowManager: Animation done in ActivityRecord{ffd4f24 u0 com.android.settings/.MainSettings} t8}: reportedVisible=false okToDisplay=true okToAnimate=true startingDisplayed=true
09-23 16:11:45.840 5050 5075 V WindowManager: Reporting visible in Token{cec9289 ActivityRecord{ffd4f24 u0 com.android.settings/.MainSettings} t8}}
09-23 16:11:45.862 5050 9625 D ActivityTaskManager: activityIdleInternal: Callers=com.android.server.wm.ActivityClientController.activityIdle:150 android.app.IActivityClientController$Stub.onTransact:558 com.android.server.wm.ActivityClientController.onTransact:131 android.os.Binder.execTransactInternal:1290
09-23 16:11:45.864 5050 9625 V WindowManager: Ready to stop: ActivityRecord{582ac5 u0 com.miui.home/.launcher.Launcher} t2}
09-23 16:11:45.865 5050 9625 I wm_stop_activity: [0,5778117,com.miui.home/.launcher.Launcher]
09-23 16:11:45.865 5050 9625 I ActivityTaskManager: activityIdleInternal(): r=ActivityRecord{ffd4f24 u0 com.android.settings/.MainSettings} t8}, mStartingUsers=[]
09-23 16:11:45.934 5050 6955 V WindowManager: Animation done in WindowStateAnimator{3b00274 com.android.settings/com.android.settings.MainSettings}: exiting=false, reportedVisible=true
09-23 16:11:46.094 5050 5075 V WindowManager: Animation done in WindowStateAnimator{73f30a7 Splash Screen com.android.settings}: exiting=true, reportedVisible=true
从App返回桌面
09-23 16:18:38.604 5050 6692 V WindowManager: Animation done in WindowStateAnimator{3b00274 com.android.settings/com.android.settings.MainSettings}: exiting=false, reportedVisible=true
09-23 16:18:38.605 5050 6692 V WindowManager: Animation done in WindowStateAnimator{2a9644e com.miui.home/com.miui.home.launcher.Launcher}: exiting=false, reportedVisible=false
09-23 16:18:38.605 5050 6692 V WindowManager: Reporting visible in Token{15ae41 ActivityRecord{582ac5 u0 com.miui.home/.launcher.Launcher} t2}}
09-23 16:18:38.624 5050 6692 I wm_add_to_stopping: [0,268259108,com.android.settings/.MainSettings,makeInvisible]
09-23 16:18:38.640 5050 6692 V WindowManager: Animation done in ActivityRecord{ffd4f24 u0 com.android.settings/.MainSettings} t8}: reportedVisible=true okToDisplay=true okToAnimate=true startingDisplayed=false
09-23 16:18:38.673 5050 5074 V WindowManager: Ready to stop: ActivityRecord{ffd4f24 u0 com.android.settings/.MainSettings} t8}
09-23 16:18:38.675 5050 5074 I wm_stop_activity: [0,268259108,com.android.settings/.MainSettings]
09-23 16:18:38.675 5050 5074 I ActivityTaskManager: activityIdleInternal(): r=null, mStartingUsers=[]
09-23 16:18:38.779 5050 6692 D ActivityTaskManager: activityIdleInternal: Callers=com.android.server.wm.ActivityClientController.activityIdle:150 android.app.IActivityClientController$Stub.onTransact:558 com.android.server.wm.ActivityClientController.onTransact:131 android.os.Binder.execTransactInternal:1290
09-23 16:18:38.782 5050 6692 I ActivityTaskManager: activityIdleInternal(): r=ActivityRecord{582ac5 u0 com.miui.home/.launcher.Launcher} t2}, mStartingUsers=[]
|