FrameTimeline: Optimize tracing information about frame start time
If the prediction state is expired but the actual start time is
available, prioritize the actual start time as the reference for the
actual timeline instead of using the actual end time.
Flag: EXEMPT. bug fix from external contributor
Signed-off-by: liuzhifu <liuzhifu@xiaomi.com>
(cherry picked from https://android-review.googlesource.com/q/commit:13eb5161b25da09feabfb9c4c89e6804da92056b)
Merged-In: I1646a159ab74b3d7918067e24c6e827bf6ae5b4e
Change-Id: I1646a159ab74b3d7918067e24c6e827bf6ae5b4e
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index 51d4078..a1328a9 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -801,6 +801,9 @@
FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) {
const auto timestamp = [&]() {
std::scoped_lock lock(mMutex);
+ if (mActuals.startTime != 0) {
+ return mActuals.startTime;
+ }
// Actual start time is not yet available, so use expected start instead
if (mPredictionState == PredictionState::Expired) {
// If prediction is expired, we can't use the predicted start time. Instead, just
@@ -811,7 +814,7 @@
return endTime - kPredictionExpiredStartTimeDelta;
}
- return mActuals.startTime == 0 ? mPredictions.startTime : mActuals.startTime;
+ return mPredictions.startTime;
}();
if (filterFramesBeforeTraceStarts && !shouldTraceForDataSource(ctx, timestamp)) {