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

Commit 5109c0da authored by Robert Carr's avatar Robert Carr
Browse files

Async BLAST Sync [2/N]: Introduce seqId

We introduce a seqId and use it to replace the
RELAYOUT_RES_BLAST_SYNC flag. The server code block that
produces RELAYOUT_RES_BLAST_SYNC is guarded by
mNextRelayoutUseSync, and sets it to false when executed.
This block is the only place that sets it to false. We replace
every place where it is set to true, with incrementing a seqId
stored on the integer. We change this block to not check
mNextRelayoutUseSync but instead check if the seqId has changed
since we reached the block. This is evidentally equivalent conditions
and in these cases we send the client the seqId. In the else block
where we wouldn't have sent RELAYOUT_RES_BLAST_SYNC we send -1.
On the client side, we replace the USE_BLAST_SYNC conditional
with a check if the SeqId we received has increased. It's clear
that this will never execute in cases where the seqId is -1. Likewise
its clear that if the seqId has increased, it will execute. Since the
seqId increases in all cases where the server would have returned
RELAYOUT_RES_BLAST_SYNC this change is a noop by itself.

Bug: 161810301
Bug: 175861051
Bug: 175861127
Bug: 200285149
Change-Id: Ib2e45cae7709519251e4bfcc2b8adc689c590a00
parent cde55d30
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -845,7 +845,8 @@ public final class ViewRootImpl implements ViewParent,
     * integer back over relayout.
     */
    private Bundle mRelayoutBundle = new Bundle();
    private int mSyncSeqId;
    private int mSyncSeqId = 0;
    private int mLastSyncSeqId = 0;

    private String mTag = TAG;

@@ -2918,7 +2919,8 @@ public final class ViewRootImpl implements ViewParent,
                final boolean dockedResizing = (relayoutResult
                        & RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
                final boolean dragResizing = freeformResizing || dockedResizing;
                if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC) != 0) {
                if (mSyncSeqId > mLastSyncSeqId) {
                    mLastSyncSeqId = mSyncSeqId;
                    if (DEBUG_BLAST) {
                        Log.d(mTag, "Relayout called with blastSync");
                    }
@@ -8086,6 +8088,7 @@ public final class ViewRootImpl implements ViewParent,
                insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
                mTempControls, mRelayoutBundle);
        mSyncSeqId = mRelayoutBundle.getInt("seqid");

        final int transformHint = SurfaceControl.rotationToBufferTransform(
                (mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
+0 −8
Original line number Diff line number Diff line
@@ -96,14 +96,6 @@ public final class WindowManagerGlobal {
     */
    public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 1 << 5;

    /**
     * This flag indicates the client should not directly submit it's next frame,
     * but instead should pass it in the postDrawTransaction of
     * {@link WindowManagerService#finishDrawing}. This is used by the WM
     * BLASTSyncEngine to synchronize rendering of multiple windows.
     */
    public static final int RELAYOUT_RES_BLAST_SYNC = 1 << 6;

    /**
     * Flag for relayout: the client will be later giving
     * internal insets; as a result, the window will not impact other window
+6 −4
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_RELAUNCH;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
import static android.view.WindowManagerPolicyConstants.TYPE_LAYER_MULTIPLIER;
@@ -2508,11 +2507,14 @@ public class WindowManagerService extends IWindowManager.Stub
            win.mInRelayout = false;

            if (mUseBLASTSync && win.useBLASTSync() && viewVisibility != View.GONE
                    && win.mNextRelayoutUseSync) {
                    && (win.mSyncSeqId > win.mLastSeqIdSentToRelayout)) {
                win.prepareDrawHandlers();
                win.markRedrawForSyncReported();
                win.mNextRelayoutUseSync = false;
                result |= RELAYOUT_RES_BLAST_SYNC;

                win.mLastSeqIdSentToRelayout = win.mSyncSeqId;
                outSyncIdBundle.putInt("seqid", win.mSyncSeqId);
            } else {
                outSyncIdBundle.putInt("seqid", -1);
            }

            if (configChanged) {
+4 −3
Original line number Diff line number Diff line
@@ -369,7 +369,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    private boolean mDragResizingChangeReported = true;
    private int mResizeMode;
    private boolean mRedrawForSyncReported;
    boolean mNextRelayoutUseSync;
    int mSyncSeqId = 0;
    int mLastSeqIdSentToRelayout = 0;

    /**
     * {@code true} when the client was still drawing for sync when the sync-set was finished or
@@ -5923,7 +5924,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // to draw even if the children draw first or don't need to sync, so we start
        // in WAITING state rather than READY.
        mSyncState = SYNC_STATE_WAITING_FOR_DRAW;
        mNextRelayoutUseSync = true;
        mSyncSeqId++;
        requestRedrawForSync();
        return true;
    }
@@ -6066,7 +6067,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     */
    void applyWithNextDraw(Consumer<SurfaceControl.Transaction> consumer) {
        mPendingDrawHandlers.add(consumer);
        mNextRelayoutUseSync = true;
        mSyncSeqId++;
        requestRedrawForSync();

        mWmService.mH.sendNewMessageDelayed(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this,