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

Commit 244c4cf7 authored by Chris Li's avatar Chris Li
Browse files

Use self sync transaction for assignLayer

When finish sync, we merge all sync root memeber's sync transaction
without any ordering. To ensure the ordering, use self sync
transaction whenever possible.

Bug: 310106489
Bug: 388127825
Test: manually test with the reproduce steps in bug
Flag: com.android.window.flags.use_self_sync_transaction_for_layer
Change-Id: I1d8d1f501e323c0bf9e0e07116dd32b4855f9619
parent b4319024
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ import com.android.server.wm.SurfaceAnimator.Animatable;
import com.android.server.wm.SurfaceAnimator.AnimationType;
import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback;
import com.android.server.wm.utils.AlwaysTruePredicate;
import com.android.window.flags.Flags;

import java.io.PrintWriter;
import java.lang.ref.WeakReference;
@@ -2730,6 +2731,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        if (!mTransitionController.canAssignLayers(this)) return;
        final boolean changed = layer != mLastLayer || mLastRelativeToLayer != null;
        if (mSurfaceControl != null && changed) {
            if (Flags.useSelfSyncTransactionForLayer() && mSyncState != SYNC_STATE_NONE) {
                // When this container needs to be synced, assign layer with its own sync
                // transaction to avoid out of ordering when merge.
                // Still use the passed-in transaction for non-sync case, such as building finish
                // transaction.
                t = getSyncTransaction();
            }
            setLayer(t, layer);
            mLastLayer = layer;
            mLastRelativeToLayer = null;
@@ -2740,6 +2748,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
            boolean forceUpdate) {
        final boolean changed = layer != mLastLayer || mLastRelativeToLayer != relativeTo;
        if (mSurfaceControl != null && (changed || forceUpdate)) {
            if (Flags.useSelfSyncTransactionForLayer() && mSyncState != SYNC_STATE_NONE) {
                // When this container needs to be synced, assign layer with its own sync
                // transaction to avoid out of ordering when merge.
                // Still use the passed-in transaction for non-sync case, such as building finish
                // transaction.
                t = getSyncTransaction();
            }
            setRelativeLayer(t, relativeTo, layer);
            mLastLayer = layer;
            mLastRelativeToLayer = relativeTo;
+7 −0
Original line number Diff line number Diff line
@@ -5547,6 +5547,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    @Override
    void assignLayer(Transaction t, int layer) {
        if (mStartingData != null) {
            if (Flags.useSelfSyncTransactionForLayer() && mSyncState != SYNC_STATE_NONE) {
                // When this container needs to be synced, assign layer with its own sync
                // transaction to avoid out of ordering when merge.
                // Still use the passed-in transaction for non-sync case, such as building finish
                // transaction.
                t = getSyncTransaction();
            }
            // The starting window should cover the task.
            t.setLayer(mSurfaceControl, Integer.MAX_VALUE);
            return;
+2 −0
Original line number Diff line number Diff line
@@ -1267,6 +1267,7 @@ public class WindowContainerTests extends WindowTestsBase {
        final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
        spyOn(container);
        spyOn(surfaceAnimator);
        doReturn(t).when(container).getSyncTransaction();

        // Trigger for first relative layer call.
        container.assignRelativeLayer(t, relativeParent, 1 /* layer */);
@@ -1293,6 +1294,7 @@ public class WindowContainerTests extends WindowTestsBase {
        spyOn(container);
        spyOn(surfaceAnimator);
        spyOn(surfaceFreezer);
        doReturn(t).when(container).getSyncTransaction();

        container.setLayer(t, 1);
        container.setRelativeLayer(t, relativeParent, 2);