Traces with real-to-elapsed time offset
Add real_to_elapsed_time_offset_nanos field to protobuf traces:
- SF layers
- SF transactions
Bug: 235196806
Test: record and view SF + transaction traces with winscope
Change-Id: I5f4d2a2b4e2ceaacf75c43d01f866fe1e2b76532
diff --git a/services/surfaceflinger/Tracing/LayerTracing.cpp b/services/surfaceflinger/Tracing/LayerTracing.cpp
index afa3e50..566d553 100644
--- a/services/surfaceflinger/Tracing/LayerTracing.cpp
+++ b/services/surfaceflinger/Tracing/LayerTracing.cpp
@@ -89,6 +89,9 @@
LayersTraceFileProto fileProto;
fileProto.set_magic_number(uint64_t(LayersTraceFileProto_MagicNumber_MAGIC_NUMBER_H) << 32 |
LayersTraceFileProto_MagicNumber_MAGIC_NUMBER_L);
+ auto timeOffsetNs = static_cast<std::uint64_t>(systemTime(SYSTEM_TIME_REALTIME) -
+ systemTime(SYSTEM_TIME_MONOTONIC));
+ fileProto.set_real_to_elapsed_time_offset_nanos(timeOffsetNs);
return fileProto;
}
diff --git a/services/surfaceflinger/Tracing/TransactionTracing.cpp b/services/surfaceflinger/Tracing/TransactionTracing.cpp
index af0594e..cb5320b 100644
--- a/services/surfaceflinger/Tracing/TransactionTracing.cpp
+++ b/services/surfaceflinger/Tracing/TransactionTracing.cpp
@@ -134,6 +134,9 @@
proto::TransactionTraceFile proto;
proto.set_magic_number(uint64_t(proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_H) << 32 |
proto::TransactionTraceFile_MagicNumber_MAGIC_NUMBER_L);
+ auto timeOffsetNs = static_cast<std::uint64_t>(systemTime(SYSTEM_TIME_REALTIME) -
+ systemTime(SYSTEM_TIME_MONOTONIC));
+ proto.set_real_to_elapsed_time_offset_nanos(timeOffsetNs);
return proto;
}
diff --git a/services/surfaceflinger/layerproto/layerstrace.proto b/services/surfaceflinger/layerproto/layerstrace.proto
index 7def024..804a499 100644
--- a/services/surfaceflinger/layerproto/layerstrace.proto
+++ b/services/surfaceflinger/layerproto/layerstrace.proto
@@ -38,6 +38,10 @@
optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */
repeated LayersTraceProto entry = 2;
+
+ /* offset between real-time clock and elapsed time clock in nanoseconds.
+ Calculated as: systemTime(SYSTEM_TIME_REALTIME) - systemTime(SYSTEM_TIME_MONOTONIC) */
+ optional fixed64 real_to_elapsed_time_offset_nanos = 3;
}
/* one layers trace entry. */
diff --git a/services/surfaceflinger/layerproto/transactions.proto b/services/surfaceflinger/layerproto/transactions.proto
index 4f99b19..49487ee 100644
--- a/services/surfaceflinger/layerproto/transactions.proto
+++ b/services/surfaceflinger/layerproto/transactions.proto
@@ -36,6 +36,10 @@
fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */
repeated TransactionTraceEntry entry = 2;
+
+ /* offset between real-time clock and elapsed time clock in nanoseconds.
+ Calculated as: systemTime(SYSTEM_TIME_REALTIME) - systemTime(SYSTEM_TIME_MONOTONIC) */
+ fixed64 real_to_elapsed_time_offset_nanos = 3;
}
message TransactionTraceEntry {