From a8b62357eb8716eaa1294552f0e8e7fd1b539f5a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 6 May 2021 11:52:33 -0700 Subject: [PATCH] Lazy initialize the choreographer Bug: 187177407 Test: Manual Change-Id: I7c593c96335d1bfafd682647b231ec1f3d8030d5 --- .../android/systemui/shared/tracing/FrameProtoTracer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/tracing/FrameProtoTracer.java b/packages/SystemUI/shared/src/com/android/systemui/shared/tracing/FrameProtoTracer.java index 356e0ca7193c1..4394ecbf79eb9 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/tracing/FrameProtoTracer.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/tracing/FrameProtoTracer.java @@ -49,7 +49,7 @@ public class FrameProtoTracer private final TraceBuffer mBuffer; private final File mTraceFile; private final ProtoTraceParams mParams; - private final Choreographer mChoreographer; + private Choreographer mChoreographer; private final Queue mPool = new LinkedList<>(); private final ArrayList> mTraceables = new ArrayList<>(); private final ArrayList> mTmpTraceables = new ArrayList<>(); @@ -94,7 +94,6 @@ public class FrameProtoTracer } }); mTraceFile = params.getTraceFile(); - mChoreographer = Choreographer.getMainThreadInstance(); } public void start() { @@ -140,6 +139,9 @@ public class FrameProtoTracer } // Schedule an update on the next frame + if (mChoreographer == null) { + mChoreographer = Choreographer.getMainThreadInstance(); + } mChoreographer.postFrameCallback(this); mFrameScheduled = true; }