Skip to content

Commit 57c29fc

Browse files
sbuggaymeta-codesync[bot]
authored andcommitted
Add optional screenshot argument to FrameTimingSequence (facebook#54743)
Summary: Pull Request resolved: facebook#54743 Instead of creating another buffer, optionally include screenshots if they are enabled in `FrameTimingSequence`. Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D87936871 fbshipit-source-id: c35ef7776f6f51281213664f98e13db0a2bbab42
1 parent 52186a3 commit 57c29fc

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/FrameTimingSequence.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ internal data class FrameTimingSequence(
1313
val beginDrawingTimestamp: Long,
1414
val commitTimestamp: Long,
1515
val endDrawingTimestamp: Long,
16+
val screenshot: String? = null,
1617
)

packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void JReactHostInspectorTarget::recordFrameTimings(
300300
frameTimingSequence->getBeginDrawingTimestamp(),
301301
frameTimingSequence->getCommitTimestamp(),
302302
frameTimingSequence->getEndDrawingTimestamp(),
303+
frameTimingSequence->getScreenshot(),
303304
});
304305
}
305306

packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ struct JFrameTimingSequence : public jni::JavaClass<JFrameTimingSequence> {
6767
return HighResTimeStamp::fromChronoSteadyClockTimePoint(
6868
std::chrono::steady_clock::time_point(std::chrono::nanoseconds(getFieldValue(field))));
6969
}
70+
71+
std::optional<std::string> getScreenshot() const
72+
{
73+
auto field = javaClassStatic()->getField<jstring>("screenshot");
74+
auto javaScreenshot = getFieldValue(field);
75+
if (javaScreenshot) {
76+
auto jstring = jni::static_ref_cast<jni::JString>(javaScreenshot);
77+
return jstring->toStdString();
78+
}
79+
return std::nullopt;
80+
}
7081
};
7182

7283
struct JReactHostImpl : public jni::JavaClass<JReactHostImpl> {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ struct FrameTimingSequence {
2424
ThreadId threadId,
2525
HighResTimeStamp beginDrawingTimestamp,
2626
HighResTimeStamp commitTimestamp,
27-
HighResTimeStamp endDrawingTimestamp)
27+
HighResTimeStamp endDrawingTimestamp,
28+
std::optional<std::string> screenshot = std::nullopt)
2829
: id(id),
2930
threadId(threadId),
3031
beginDrawingTimestamp(beginDrawingTimestamp),
3132
commitTimestamp(commitTimestamp),
32-
endDrawingTimestamp(endDrawingTimestamp)
33+
endDrawingTimestamp(endDrawingTimestamp),
34+
screenshot(std::move(screenshot))
3335
{
3436
}
3537

@@ -46,6 +48,11 @@ struct FrameTimingSequence {
4648
HighResTimeStamp beginDrawingTimestamp;
4749
HighResTimeStamp commitTimestamp;
4850
HighResTimeStamp endDrawingTimestamp;
51+
52+
/**
53+
* Optional screenshot data (base64 encoded) captured during the frame.
54+
*/
55+
std::optional<std::string> screenshot;
4956
};
5057

5158
} // namespace facebook::react::jsinspector_modern::tracing

0 commit comments

Comments
 (0)