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

Commit e9d61ec1 authored by Winson Chung's avatar Winson Chung
Browse files

Reset the remote transition references on the main shell thread

- Hypothetically, if the remote transition references is cleared on the
  binder thread, a pending to-be-merged transition would preempt the
  onTransitionFinished() callback leading to a crash
- Also add additional logs that can confirm this case if it happens
  again (ie. log that the remote transition is calling finish in
  addition to the basic transition finished/merged logs)

Bug: 285935417
Test: Presubmit
Change-Id: Ie0efc15b928010fab3e88f358e3d474e38c138f0
parent fbae6c48
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -451,6 +451,8 @@ class SplitScreenTransitions {
            mPendingResize.onConsumed(aborted);
            mPendingResize = null;
        }

        // TODO: handle transition consumed for active remote handler
    }

    void onFinish(WindowContainerTransaction wct) {
+13 −3
Original line number Diff line number Diff line
@@ -74,6 +74,9 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
            @Override
            public void onTransitionFinished(WindowContainerTransaction wct,
                    SurfaceControl.Transaction sct) {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                        "Finished one-shot remote transition %s for (#%d).", mRemote,
                        info.getDebugId());
                if (mRemote.asBinder() != null) {
                    mRemote.asBinder().unlinkToDeath(remoteDied, 0 /* flags */);
                }
@@ -82,8 +85,8 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
                }
                mMainExecutor.execute(() -> {
                    finishCallback.onTransitionFinished(wct);
                });
                    mRemote = null;
                });
            }
        };
        Transitions.setRunningRemoteTransitionDelegate(mRemote.getAppThread());
@@ -115,17 +118,24 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
    public void mergeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction t, @NonNull IBinder mergeTarget,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Merging registered One-shot remote"
                + " transition %s for (#%d).", mRemote, info.getDebugId());
        IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
            @Override
            public void onTransitionFinished(WindowContainerTransaction wct,
                    SurfaceControl.Transaction sct) {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                        "Finished merging one-shot remote transition %s for (#%d).", mRemote,
                        info.getDebugId());
                // We have merged, since we sent the transaction over binder, the one in this
                // process won't be cleared if the remote applied it. We don't actually know if the
                // remote applied the transaction, but applying twice will break surfaceflinger
                // so just assume the worst-case and clear the local transaction.
                t.clear();
                mMainExecutor.execute(() -> finishCallback.onTransitionFinished(wct));
                mMainExecutor.execute(() -> {
                    finishCallback.onTransitionFinished(wct);
                    mRemote = null;
                });
            }
        };
        try {