Take snapshot directly during change transition
Using the tasksnapshotcontroller here is actually wrong... the
snapshot being created is already out-of-date and could have
scaling/other things applied to it. Additionally, it can clash
with things listening for task-snapshot changes which is also
wrong.
This changes to getting a snapshot directly which is more
correct and faster (since it doesn't go through the snapshot
controller's caching thing).
Bug: 132783168
Test: Manual, change transitions still work. android on chrome
doesn't crash on tablet-mode switch
Change-Id: I726ed174765ac64bedb7cd130719190a06ad42ab
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 3d7e50d..cae7612 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -1733,17 +1733,13 @@
return;
}
- if (mThumbnail == null && getTask() != null) {
- final TaskSnapshotController snapshotCtrl = mWmService.mTaskSnapshotController;
- final ArraySet<Task> tasks = new ArraySet<>();
- tasks.add(getTask());
- snapshotCtrl.snapshotTasks(tasks);
- snapshotCtrl.addSkipClosingAppSnapshotTasks(tasks);
- final ActivityManager.TaskSnapshot snapshot = snapshotCtrl.getSnapshot(
- getTask().mTaskId, getTask().mUserId, false /* restoreFromDisk */,
- false /* reducedResolution */);
+ Task task = getTask();
+ if (mThumbnail == null && task != null && !hasCommittedReparentToAnimationLeash()) {
+ SurfaceControl.ScreenshotGraphicBuffer snapshot =
+ mWmService.mTaskSnapshotController.createTaskSnapshot(
+ task, 1 /* scaleFraction */);
if (snapshot != null) {
- mThumbnail = new AppWindowThumbnail(t, this, snapshot.getSnapshot(),
+ mThumbnail = new AppWindowThumbnail(t, this, snapshot.getGraphicBuffer(),
true /* relative */);
}
}
@@ -2858,7 +2854,7 @@
}
}
t.hide(mTransitChangeLeash);
- t.reparent(mTransitChangeLeash, null);
+ t.remove(mTransitChangeLeash);
mTransitChangeLeash = null;
if (cancel) {
onAnimationLeashLost(t);