diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp index 6ff316aec34..424b9ad11b8 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp @@ -34,7 +34,7 @@ bool PerformanceTracer::startTracing() { } tracingAtomic_ = true; - + currentTraceStartTime_ = HighResTimeStamp::now(); return true; } @@ -60,6 +60,17 @@ std::optional> PerformanceTracer::stopTracing() { // samples will be displayed as empty. We use these events to avoid that. // This could happen for non-bridgeless apps, where Performance interface is // not supported and no spec-compliant Event Loop implementation. + + events.emplace_back(TraceEvent{ + .name = "TracingStartedInPage", + .cat = "disabled-by-default-devtools.timeline", + .ph = 'I', + .ts = currentTraceStartTime_, + .pid = processId_, + .tid = oscompat::getCurrentThreadId(), + .args = folly::dynamic::object("data", folly::dynamic::object()), + }); + events.emplace_back(TraceEvent{ .name = "ReactNative-TracingStopped", .cat = "disabled-by-default-devtools.timeline", diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h index 533a6c388c9..7b83cff0a4e 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h @@ -149,7 +149,10 @@ class PerformanceTracer { */ uint32_t performanceMeasureCount_{0}; + HighResTimeStamp currentTraceStartTime_; + std::vector buffer_; + /** * Protects data members of this class for concurrent access, including * the tracingAtomic_, in order to eliminate potential "logic" races.