Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47308691 authored by Jerry Chang's avatar Jerry Chang
Browse files

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
parent 99933f97
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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);