diff options
| author | 2023-08-08 10:27:41 +0000 | |
|---|---|---|
| committer | 2023-08-11 12:02:36 +0000 | |
| commit | dea7e1e6513e35074126ea2d21c429b6ee6886cc (patch) | |
| tree | 57c2dd33e564dbfe357fccfd661fe2153dfaf51f | |
| parent | f2bc3386e47cb5f81135a8c3ae4467e5d775f660 (diff) | |
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
5 files changed, 30 insertions, 1 deletions
diff --git a/core/proto/android/server/windowmanagertransitiontrace.proto b/core/proto/android/server/windowmanagertransitiontrace.proto index a950a79d94fb..34ccb482fb14 100644 --- a/core/proto/android/server/windowmanagertransitiontrace.proto +++ b/core/proto/android/server/windowmanagertransitiontrace.proto @@ -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 { diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 62273b5bc445..4ba60268cd83 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -2785,6 +2785,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else if (isEmbedded()) { associateStartingWindowWithTaskIfNeeded(); } + if (mTransitionController.isCollecting()) { + mStartingData.mTransitionId = mTransitionController.getCollectingTransitionId(); + } } } diff --git a/services/core/java/com/android/server/wm/StartingData.java b/services/core/java/com/android/server/wm/StartingData.java index 2b22d75693fe..34806bd023a0 100644 --- a/services/core/java/com/android/server/wm/StartingData.java +++ b/services/core/java/com/android/server/wm/StartingData.java @@ -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; diff --git a/services/core/java/com/android/server/wm/TransitionTracer.java b/services/core/java/com/android/server/wm/TransitionTracer.java index af8fb0252675..c59d2d392e93 100644 --- a/services/core/java/com/android/server/wm/TransitionTracer.java +++ b/services/core/java/com/android/server/wm/TransitionTracer.java @@ -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"); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b2a2452f1123..49b8af380731 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -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 |