Prevent updating invlid child task surfaces in the sync queue

The task surface might be released before running in the sync queue for
the case like trampoline launch, so check if the surface is valid before
processing it in StageTaskListener.

Fix: 239490752
Test: atest WMShellUnitTests
Test: no crash when dragging a "clean" shortcut of Files to enter split
Change-Id: I8f927f644149cf9b24f4c9110f8ac745bb558dcd
This commit is contained in:
Jerry Chang
2022-08-05 03:09:30 +00:00
parent 99933f97b6
commit 4730869154

View File

@@ -32,6 +32,7 @@ import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
import android.util.Slog;
import android.util.SparseArray;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -361,7 +362,13 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
SurfaceControl leash, boolean firstAppeared) {
final Point taskPositionInParent = taskInfo.positionInParent;
mSyncQueue.runInSync(t -> {
t.setWindowCrop(leash, null);
// The task surface might be released before running in the sync queue for the case like
// trampoline launch, so check if the surface is valid before processing it.
if (!leash.isValid()) {
Slog.w(TAG, "Skip updating invalid child task surface of task#" + taskInfo.taskId);
return;
}
t.setCrop(leash, null);
t.setPosition(leash, taskPositionInParent.x, taskPositionInParent.y);
if (firstAppeared && !ENABLE_SHELL_TRANSITIONS) {
t.setAlpha(leash, 1f);