From 2bff4a96cfdb650b229020c3cbccdbc1aaf2fc1e Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Fri, 5 May 2023 16:18:00 -0700 Subject: [PATCH] Don't prematurely apply finishT in taskview handler The finish-transaction is supposed to be applied by the transition player since the order matters. By applying it in TaskViewTransitions, it was causing operations to run out-of-order leaving broken surface hierarchies. This removes the erroneous apply() calls. Also, set surface position to 0,0 on surfaceChanged to match surfaceCreated -- otherwise we end up with a double offset. Bug: 277759491 Test: open new homecontrols from dream (observe no offset), then close them via the X button (should return to dream). Change-Id: I4527df33b29ad93045928d8e73b0698a36d95081 --- .../android/wm/shell/taskview/TaskViewTaskController.java | 8 +++----- .../android/wm/shell/taskview/TaskViewTransitions.java | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTaskController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTaskController.java index 94190c74f3e9b..d27933e2f8008 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTaskController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTaskController.java @@ -453,7 +453,7 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { return; } - finishTransaction.reparent(mTaskLeash, null).apply(); + finishTransaction.reparent(mTaskLeash, null); if (mListener != null) { final int taskId = mTaskInfo.taskId; @@ -490,13 +490,11 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { if (mSurfaceCreated) { // Surface is ready, so just reparent the task to this surface control startTransaction.reparent(mTaskLeash, mSurfaceControl) - .show(mTaskLeash) - .apply(); + .show(mTaskLeash); // Also reparent on finishTransaction since the finishTransaction will reparent back // to its "original" parent by default. finishTransaction.reparent(mTaskLeash, mSurfaceControl) - .setPosition(mTaskLeash, 0, 0) - .apply(); + .setPosition(mTaskLeash, 0, 0); mTaskViewTransitions.updateBoundsState(this, mTaskViewBase.getCurrentBoundsOnScreen()); mTaskViewTransitions.updateVisibilityState(this, true /* visible */); wct.setBounds(mTaskToken, mTaskViewBase.getCurrentBoundsOnScreen()); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java index 689f9e1a3eda9..fe2faaf79a1a2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java @@ -363,7 +363,8 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { continue; } startTransaction.reparent(chg.getLeash(), tv.getSurfaceControl()); - finishTransaction.reparent(chg.getLeash(), tv.getSurfaceControl()); + finishTransaction.reparent(chg.getLeash(), tv.getSurfaceControl()) + .setPosition(chg.getLeash(), 0, 0); changesHandled++; } } @@ -377,7 +378,6 @@ public class TaskViewTransitions implements Transitions.TransitionHandler { } // No animation, just show it immediately. startTransaction.apply(); - finishTransaction.apply(); finishCallback.onTransitionFinished(wct, null /* wctCB */); startNextTransition(); return true;