Skip to content

Commit 91d4332

Browse files
sbuggaymeta-codesync[bot]
authored andcommitted
Expose frame events on PerformanceTracer (#54361)
Summary: Pull Request resolved: #54361 Expose a couple frame related events on the PerformanceTracer and call setLayerTreeId when tracing starts (needed for DevTools to parse frames) Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D85145809 fbshipit-source-id: 421ee5441041da64f486f5492fa6705b965751f9
1 parent ce259c5 commit 91d4332

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,41 @@ void PerformanceTracer::reportResourceFinish(
360360
});
361361
}
362362

363+
void PerformanceTracer::setLayerTreeId(std::string frame, int layerTreeId) {
364+
enqueueEvent(
365+
PerformanceTracerSetLayerTreeIdEvent{
366+
.frame = std::move(frame),
367+
.layerTreeId = layerTreeId,
368+
.start = HighResTimeStamp::now(),
369+
.threadId = getCurrentThreadId(),
370+
});
371+
}
372+
373+
void PerformanceTracer::reportFrameTiming(
374+
int frameSeqId,
375+
HighResTimeStamp start,
376+
HighResTimeStamp end) {
377+
ThreadId threadId = getCurrentThreadId();
378+
enqueueEvent(
379+
PerformanceTracerFrameBeginDrawEvent{
380+
.frameSeqId = frameSeqId,
381+
.start = start,
382+
.threadId = threadId,
383+
});
384+
enqueueEvent(
385+
PerformanceTracerFrameCommitEvent{
386+
.frameSeqId = frameSeqId,
387+
.start = start,
388+
.threadId = threadId,
389+
});
390+
enqueueEvent(
391+
PerformanceTracerFrameDrawEvent{
392+
.frameSeqId = frameSeqId,
393+
.start = end,
394+
.threadId = threadId,
395+
});
396+
}
397+
363398
/* static */ TraceEvent PerformanceTracer::constructRuntimeProfileTraceEvent(
364399
RuntimeProfileId profileId,
365400
ProcessId processId,

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ class PerformanceTracer {
161161
int encodedDataLength,
162162
int decodedBodyLength);
163163

164+
/**
165+
* Sets the active layer tree ID in Chrome DevTools. This is needed in
166+
* order for frames to be parsed.
167+
*
168+
* https://chromedevtools.github.io/devtools-protocol/tot/LayerTree/
169+
*/
170+
void setLayerTreeId(std::string frame, int layerTreeId);
171+
172+
/**
173+
* Reports the required frame CDP events for a given native frame.
174+
*/
175+
void reportFrameTiming(int frameSeqId, HighResTimeStamp start, HighResTimeStamp end);
176+
164177
/**
165178
* Creates "Profile" Trace Event.
166179
*

0 commit comments

Comments
 (0)