summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2021-04-29 22:37:42 +0800
committer Riddle Hsu <riddlehsu@google.com> 2021-05-10 13:39:57 +0000
commitd3bdc63ca1cf6a3e0714201dbad23c761bc6ec4a (patch)
treedb3b83f56ae9a3ad0b6ffe0d474131bd43d62062
parent393c625a54226f24f499c63bbd643133f72d52d8 (diff)
Attempt to fix race of task surface visibility
1. Remove TaskOrganizerController#mTransaction because the standalone transaction may not be synced with pending transaction of window container and WMShell. That may cause potential race such as reverting the task surface visibility. The transaction was added in commit 14a657c for the case of entering PiP. Since commit 6567742, the task will be moved to back when setForceHidden, so it is already invisible. So the removal of 14a657c doesn't affect the PiP case. 2. Make task surface default invisible if the task can be organized, so the extra hide operation can be eliminated. That simplifies the control of task surface visibility. Bug: 185400889 Test: atest FlickerTests WMShellFlickerTests Change-Id: I29d80acce2019a7d01a09e98112bc07763c9054b
-rw-r--r--services/core/java/com/android/server/wm/Task.java25
-rw-r--r--services/core/java/com/android/server/wm/TaskOrganizerController.java24
2 files changed, 10 insertions, 39 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index e5e1a7a245d6..647a53c469b5 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -4971,12 +4971,13 @@ class Task extends WindowContainer<WindowContainer> {
@Override
boolean showSurfaceOnCreation() {
+ if (mCreatedByOrganizer) {
+ // Tasks created by the organizer are default visible because they can synchronously
+ // update the leash before new children are added to the task.
+ return true;
+ }
// Organized tasks handle their own surface visibility
- final boolean willBeOrganized =
- mAtmService.mTaskOrganizerController.isSupportedWindowingMode(getWindowingMode())
- && isRootTask();
- return !mAtmService.getTransitionController().isShellTransitionsEnabled()
- || !willBeOrganized;
+ return !canBeOrganized();
}
@Override
@@ -4992,22 +4993,8 @@ class Task extends WindowContainer<WindowContainer> {
}
void setHasBeenVisible(boolean hasBeenVisible) {
- final boolean prevHasBeenVisible = mHasBeenVisible;
mHasBeenVisible = hasBeenVisible;
if (hasBeenVisible) {
- // If the task is not yet visible when it is added to the task organizer, then we should
- // hide it to allow the task organizer to show it when it is properly reparented. We
- // skip this for tasks created by the organizer because they can synchronously update
- // the leash before new children are added to the task. Also skip this if the task
- // has already been sent to the organizer which can happen before the first draw if
- // an existing task is reported to the organizer when it first registers.
- if (!mAtmService.getTransitionController().isShellTransitionsEnabled()
- && !mCreatedByOrganizer && !mTaskAppearedSent
- && mTaskOrganizer != null && !prevHasBeenVisible) {
- getSyncTransaction().hide(getSurfaceControl());
- commitPendingTransaction();
- }
-
if (!mDeferTaskAppear) sendTaskAppeared();
if (!isRootTask()) {
getRootTask().setHasBeenVisible(true);
diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java
index fb481b41c0af..97c646109b72 100644
--- a/services/core/java/com/android/server/wm/TaskOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java
@@ -215,23 +215,15 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
}
}
- SurfaceControl prepareLeash(Task task, boolean visible, String reason) {
- SurfaceControl outSurfaceControl = new SurfaceControl(task.getSurfaceControl(), reason);
- if (!task.mCreatedByOrganizer && !visible) {
- // To prevent flashes, we hide the task prior to sending the leash to the
- // task org if the task has previously hidden (ie. when entering PIP)
- mTransaction.hide(outSurfaceControl);
- mTransaction.apply();
- }
- return outSurfaceControl;
+ SurfaceControl prepareLeash(Task task, String reason) {
+ return new SurfaceControl(task.getSurfaceControl(), reason);
}
void onTaskAppeared(Task task) {
ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Task appeared taskId=%d", task.mTaskId);
- final boolean visible = task.isVisible();
final RunningTaskInfo taskInfo = task.getTaskInfo();
try {
- mTaskOrganizer.onTaskAppeared(taskInfo, prepareLeash(task, visible,
+ mTaskOrganizer.onTaskAppeared(taskInfo, prepareLeash(task,
"TaskOrganizerController.onTaskAppeared"));
} catch (RemoteException e) {
Slog.e(TAG, "Exception sending onTaskAppeared callback", e);
@@ -331,7 +323,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
if (!mOrganizedTasks.contains(t)) {
mOrganizedTasks.add(t);
}
- return mOrganizer.prepareLeash(t, t.isVisible(), reason);
+ return mOrganizer.prepareLeash(t, reason);
}
private boolean addTask(Task t) {
@@ -434,7 +426,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
// Set of organized tasks (by taskId) that dispatch back pressed to their organizers
private final HashSet<Integer> mInterceptBackPressedOnRootTasks = new HashSet();
- private SurfaceControl.Transaction mTransaction;
private RunningTaskInfo mTmpTaskInfo;
private Consumer<Runnable> mDeferTaskOrgCallbacksConsumer;
@@ -479,13 +470,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
synchronized (mGlobalLock) {
ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Register task organizer=%s uid=%d",
organizer.asBinder(), uid);
-
- // Defer initializing the transaction since the transaction factory can be set up
- // by the tests after construction of the controller
- if (mTransaction == null) {
- mTransaction = mService.mWindowManager.mTransactionFactory.get();
- }
-
if (!mTaskOrganizerStates.containsKey(organizer.asBinder())) {
mTaskOrganizers.add(organizer);
mTaskOrganizerStates.put(organizer.asBinder(),