[DO NOT MERGE] Log Winscope tracing with the frame composition time
Currently the tracing log takes the current timestamp for the log entry.
However, the tracing start after the frame is composed. On winscope
this result in the trace entry being linked to the incorrect video
frame (screenrecord). Now we obtain the frame composition time (before
the frame is send to the video recorder) and use this time for the log
entry.
Test: Log a SF trace and screen recording. Open both on winscope.
Change-Id: I81a88ef7a81a084f2ecf75bf5574a1118301a48e
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index 9053f2c..5d9be0b 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -68,8 +68,9 @@
return mEnabled;
}
-void SurfaceTracing::notify(const char* where) {
+void SurfaceTracing::notify(long compositionTime, const char* where) {
std::scoped_lock lock(mSfLock);
+ mCompositionTime = compositionTime;
mWhere = where;
mCanStartTrace.notify_one();
}
@@ -160,7 +161,7 @@
ATRACE_CALL();
LayersTraceProto entry;
- entry.set_elapsed_realtime_nanos(elapsedRealtimeNano());
+ entry.set_elapsed_realtime_nanos(mCompositionTime);
entry.set_where(where);
LayersProto layers(mFlinger.dumpDrawingStateProto(mTraceFlags));
entry.mutable_layers()->Swap(&layers);