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

Commit dea7e1e6 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add removal time of starting window in transition trace proto

The transition can play with the starting window, and even if the
transition is finished, the app window may still not draw yet.
Then at the timestamp of removing the starting window, this log
can provide the info for flicker detection to check that the app
is drawn or not.

Bug: 284302118
Test: The app surface is visible at timestamp of remove_time_ns
Change-Id: I869b5a1213b7b64c4a875a9ac33c8245fcccf40f
parent f2bc3386
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ message Transition {
  repeated Target targets = 8;
  optional int32 flags = 9;
  optional int64 abort_time_ns = 10;
  optional int64 starting_window_remove_time_ns = 11;
}

message Target {
+3 −0
Original line number Diff line number Diff line
@@ -2785,6 +2785,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else if (isEmbedded()) {
                associateStartingWindowWithTaskIfNeeded();
            }
            if (mTransitionController.isCollecting()) {
                mStartingData.mTransitionId = mTransitionController.getCollectingTransitionId();
            }
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ public abstract class StartingData {
    /** Whether to prepare the removal animation. */
    boolean mPrepareRemoveAnimation;

    /** Non-zero if this starting window is added in a collecting transition. */
    int mTransitionId;

    protected StartingData(WindowManagerService service, int typeParams) {
        mService = service;
        mTypeParams = typeParams;
+21 −0
Original line number Diff line number Diff line
@@ -145,6 +145,27 @@ public class TransitionTracer {
        }
    }

    void logRemovingStartingWindow(@NonNull StartingData startingData) {
        if (startingData.mTransitionId == 0) {
            return;
        }
        try {
            final ProtoOutputStream outputStream = new ProtoOutputStream(CHUNK_SIZE);
            final long protoToken = outputStream
                    .start(com.android.server.wm.shell.TransitionTraceProto.TRANSITIONS);
            outputStream.write(com.android.server.wm.shell.Transition.ID,
                    startingData.mTransitionId);
            outputStream.write(
                    com.android.server.wm.shell.Transition.STARTING_WINDOW_REMOVE_TIME_NS,
                    SystemClock.elapsedRealtimeNanos());
            outputStream.end(protoToken);

            mTraceBuffer.add(outputStream);
        } catch (Exception e) {
            Log.e(LOG_TAG, "Unexpected exception thrown while logging transitions", e);
        }
    }

    private void dumpTransitionTargetsToProto(ProtoOutputStream outputStream,
            Transition transition, ArrayList<ChangeInfo> targets) {
        Trace.beginSection("TransitionTracer#dumpTransitionTargetsToProto");
+2 −1
Original line number Diff line number Diff line
@@ -2410,7 +2410,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                "removeIfPossible: %s callers=%s", this, Debug.getCallers(5));

        final boolean startingWindow = mAttrs.type == TYPE_APPLICATION_STARTING;
        final boolean startingWindow = mStartingData != null;
        if (startingWindow) {
            ProtoLog.d(WM_DEBUG_STARTING_WINDOW, "Starting window removed %s", this);
            // Cancel the remove starting window animation on shell. The main window might changed
@@ -2424,6 +2424,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    return false;
                }, true);
            }
            mTransitionController.mTransitionTracer.logRemovingStartingWindow(mStartingData);
        } else if (mAttrs.type == TYPE_BASE_APPLICATION
                && isSelfAnimating(0, ANIMATION_TYPE_STARTING_REVEAL)) {
            // Cancel the remove starting window animation in case the binder dead before remove