diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp index d2f04fca875..d596decb121 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp @@ -360,6 +360,41 @@ void PerformanceTracer::reportResourceFinish( }); } +void PerformanceTracer::setLayerTreeId(std::string frame, int layerTreeId) { + enqueueEvent( + PerformanceTracerSetLayerTreeIdEvent{ + .frame = std::move(frame), + .layerTreeId = layerTreeId, + .start = HighResTimeStamp::now(), + .threadId = getCurrentThreadId(), + }); +} + +void PerformanceTracer::reportFrameTiming( + int frameSeqId, + HighResTimeStamp start, + HighResTimeStamp end) { + ThreadId threadId = getCurrentThreadId(); + enqueueEvent( + PerformanceTracerFrameBeginDrawEvent{ + .frameSeqId = frameSeqId, + .start = start, + .threadId = threadId, + }); + enqueueEvent( + PerformanceTracerFrameCommitEvent{ + .frameSeqId = frameSeqId, + .start = start, + .threadId = threadId, + }); + enqueueEvent( + PerformanceTracerFrameDrawEvent{ + .frameSeqId = frameSeqId, + .start = end, + .threadId = threadId, + }); +} + /* static */ TraceEvent PerformanceTracer::constructRuntimeProfileTraceEvent( RuntimeProfileId profileId, ProcessId processId, diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h index d60eb265d78..f763cc8597b 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h @@ -161,6 +161,19 @@ class PerformanceTracer { int encodedDataLength, int decodedBodyLength); + /** + * Sets the active layer tree ID in Chrome DevTools. This is needed in + * order for frames to be parsed. + * + * https://chromedevtools.github.io/devtools-protocol/tot/LayerTree/ + */ + void setLayerTreeId(std::string frame, int layerTreeId); + + /** + * Reports the required frame CDP events for a given native frame. + */ + void reportFrameTiming(int frameSeqId, HighResTimeStamp start, HighResTimeStamp end); + /** * Creates "Profile" Trace Event. *