react-native 0.82.0-nightly-20250728-869a976a5 → 0.82.0-nightly-20250729-e17e3e3f3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/Libraries/Components/Pressable/Pressable.js +9 -0
  2. package/Libraries/Core/ReactNativeVersion.js +1 -1
  3. package/React/Base/RCTVersion.m +1 -1
  4. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +3 -0
  5. package/ReactAndroid/gradle.properties +1 -1
  6. package/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt +16 -10
  7. package/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +13 -4
  8. package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +2 -3
  9. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  10. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  11. package/ReactCommon/hermes/inspector-modern/chrome/HermesRuntimeSamplingProfileSerializer.cpp +22 -18
  12. package/ReactCommon/jsi/jsi/test/testlib.cpp +3 -1
  13. package/ReactCommon/jsinspector-modern/InstanceAgent.cpp +3 -1
  14. package/ReactCommon/jsinspector-modern/TracingAgent.cpp +4 -3
  15. package/ReactCommon/jsinspector-modern/tracing/InstanceTracingProfile.h +1 -9
  16. package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +14 -35
  17. package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +2 -11
  18. package/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfile.h +30 -110
  19. package/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfileTraceEventSerializer.cpp +43 -39
  20. package/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfileTraceEventSerializer.h +7 -8
  21. package/ReactCommon/jsinspector-modern/tracing/TraceEventProfile.h +4 -62
  22. package/ReactCommon/jsinspector-modern/tracing/TraceEventSerializer.cpp +111 -0
  23. package/ReactCommon/jsinspector-modern/tracing/TraceEventSerializer.h +93 -0
  24. package/ReactCommon/jsinspector-modern/tracing/tests/RuntimeSamplingProfileTraceEventSerializerTest.cpp +8 -8
  25. package/ReactCommon/react/renderer/imagemanager/ImageManager.h +8 -0
  26. package/ReactCommon/react/utils/ContextContainer.h +3 -0
  27. package/package.json +8 -8
  28. package/sdks/hermesc/osx-bin/hermes +0 -0
  29. package/sdks/hermesc/osx-bin/hermesc +0 -0
  30. package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
  31. package/types_generated/Libraries/Components/Pressable/Pressable.d.ts +6 -1
@@ -116,6 +116,12 @@ type PressableBaseProps = $ReadOnly<{
116
116
  */
117
117
  onPressOut?: ?(event: GestureResponderEvent) => mixed,
118
118
 
119
+ /**
120
+ * Whether to prevent any other native components from becoming responder
121
+ * while this pressable is responder.
122
+ */
123
+ blockNativeResponder?: ?boolean,
124
+
119
125
  /**
120
126
  * Either view styles or a function that receives a boolean reflecting whether
121
127
  * the component is currently pressed and returns view styles.
@@ -183,6 +189,7 @@ function Pressable({
183
189
  'aria-expanded': ariaExpanded,
184
190
  'aria-label': ariaLabel,
185
191
  'aria-selected': ariaSelected,
192
+ blockNativeResponder,
186
193
  cancelable,
187
194
  children,
188
195
  delayHoverIn,
@@ -294,10 +301,12 @@ function Pressable({
294
301
  onPressOut(event);
295
302
  }
296
303
  },
304
+ blockNativeResponder,
297
305
  }),
298
306
  [
299
307
  android_disableSound,
300
308
  android_rippleConfig,
309
+ blockNativeResponder,
301
310
  cancelable,
302
311
  delayHoverIn,
303
312
  delayHoverOut,
@@ -29,7 +29,7 @@ export default class ReactNativeVersion {
29
29
  static major: number = 0;
30
30
  static minor: number = 82;
31
31
  static patch: number = 0;
32
- static prerelease: string | null = 'nightly-20250728-869a976a5';
32
+ static prerelease: string | null = 'nightly-20250729-e17e3e3f3';
33
33
 
34
34
  static getVersionString(): string {
35
35
  return `${this.major}.${this.minor}.${this.patch}${this.prerelease != null ? `-${this.prerelease}` : ''}`;
@@ -24,7 +24,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(82),
26
26
  RCTVersionPatch: @(0),
27
- RCTVersionPrerelease: @"nightly-20250728-869a976a5",
27
+ RCTVersionPrerelease: @"nightly-20250729-e17e3e3f3",
28
28
  };
29
29
  });
30
30
  return __rnVersion;
@@ -377,6 +377,9 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
377
377
  _lastStringStateWasUpdatedWith = nil;
378
378
  _ignoreNextTextInputCall = NO;
379
379
  _didMoveToWindow = NO;
380
+ _backedTextInputView.inputAccessoryViewID = nil;
381
+ _backedTextInputView.inputAccessoryView = nil;
382
+ _hasInputAccessoryView = false;
380
383
  [_backedTextInputView resignFirstResponder];
381
384
  }
382
385
 
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.82.0-nightly-20250728-869a976a5
1
+ VERSION_NAME=0.82.0-nightly-20250729-e17e3e3f3
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -9,11 +9,12 @@ package com.facebook.react
9
9
 
10
10
  import android.view.KeyEvent
11
11
  import android.view.View
12
+ import com.facebook.react.bridge.ReactContext
12
13
  import com.facebook.react.bridge.WritableMap
13
14
  import com.facebook.react.bridge.WritableNativeMap
14
15
 
15
16
  /** Responsible for dispatching events specific for hardware inputs. */
16
- internal class ReactAndroidHWInputDeviceHelper(private val reactRootView: ReactRootView) {
17
+ internal class ReactAndroidHWInputDeviceHelper() {
17
18
  /**
18
19
  * We keep a reference to the last focused view id so that we can send it as a target for key
19
20
  * events and be able to send a blur event when focus changes.
@@ -21,36 +22,41 @@ internal class ReactAndroidHWInputDeviceHelper(private val reactRootView: ReactR
21
22
  private var lastFocusedViewId = View.NO_ID
22
23
 
23
24
  /** Called from [ReactRootView]. This is the main place the key events are handled. */
24
- fun handleKeyEvent(ev: KeyEvent) {
25
+ fun handleKeyEvent(ev: KeyEvent, context: ReactContext) {
25
26
  val eventKeyCode = ev.keyCode
26
27
  val eventKeyAction = ev.action
27
28
  if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) &&
28
29
  KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
29
- dispatchEvent(KEY_EVENTS_ACTIONS[eventKeyCode], lastFocusedViewId, eventKeyAction)
30
+ dispatchEvent(context, KEY_EVENTS_ACTIONS[eventKeyCode], lastFocusedViewId, eventKeyAction)
30
31
  }
31
32
  }
32
33
 
33
34
  /** Called from [ReactRootView] when focused view changes. */
34
- fun onFocusChanged(newFocusedView: View) {
35
+ fun onFocusChanged(newFocusedView: View, context: ReactContext) {
35
36
  if (lastFocusedViewId == newFocusedView.id) {
36
37
  return
37
38
  }
38
39
  if (lastFocusedViewId != View.NO_ID) {
39
- dispatchEvent("blur", lastFocusedViewId)
40
+ dispatchEvent(context, "blur", lastFocusedViewId)
40
41
  }
41
42
  lastFocusedViewId = newFocusedView.id
42
- dispatchEvent("focus", newFocusedView.id)
43
+ dispatchEvent(context, "focus", newFocusedView.id)
43
44
  }
44
45
 
45
46
  /** Called from [ReactRootView] when the whole view hierarchy looses focus. */
46
- fun clearFocus() {
47
+ fun clearFocus(context: ReactContext) {
47
48
  if (lastFocusedViewId != View.NO_ID) {
48
- dispatchEvent("blur", lastFocusedViewId)
49
+ dispatchEvent(context, "blur", lastFocusedViewId)
49
50
  }
50
51
  lastFocusedViewId = View.NO_ID
51
52
  }
52
53
 
53
- private fun dispatchEvent(eventType: String?, targetViewId: Int, eventKeyAction: Int = -1) {
54
+ private fun dispatchEvent(
55
+ context: ReactContext,
56
+ eventType: String?,
57
+ targetViewId: Int,
58
+ eventKeyAction: Int = -1,
59
+ ) {
54
60
  val event: WritableMap =
55
61
  WritableNativeMap().apply {
56
62
  putString("eventType", eventType)
@@ -59,7 +65,7 @@ internal class ReactAndroidHWInputDeviceHelper(private val reactRootView: ReactR
59
65
  putInt("tag", targetViewId)
60
66
  }
61
67
  }
62
- reactRootView.sendEvent("onHWKeyEvent", event)
68
+ context.emitDeviceEvent("onHWKeyEvent", event)
63
69
  }
64
70
 
65
71
  private companion object {
@@ -106,7 +106,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
106
106
  private @Nullable JSTouchDispatcher mJSTouchDispatcher;
107
107
  private @Nullable JSPointerDispatcher mJSPointerDispatcher;
108
108
  private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper =
109
- new ReactAndroidHWInputDeviceHelper(this);
109
+ new ReactAndroidHWInputDeviceHelper();
110
110
  private boolean mWasMeasured = false;
111
111
  private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
112
112
  private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
@@ -328,7 +328,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
328
328
  FLog.w(TAG, "Unable to handle key event as the catalyst instance has not been attached");
329
329
  return super.dispatchKeyEvent(ev);
330
330
  }
331
- mAndroidHWInputDeviceHelper.handleKeyEvent(ev);
331
+ ReactContext context = getCurrentReactContext();
332
+ if (context != null) {
333
+ mAndroidHWInputDeviceHelper.handleKeyEvent(ev, context);
334
+ }
332
335
  return super.dispatchKeyEvent(ev);
333
336
  }
334
337
 
@@ -341,7 +344,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
341
344
  super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
342
345
  return;
343
346
  }
344
- mAndroidHWInputDeviceHelper.clearFocus();
347
+ ReactContext context = getCurrentReactContext();
348
+ if (context != null) {
349
+ mAndroidHWInputDeviceHelper.clearFocus(context);
350
+ }
345
351
  super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
346
352
  }
347
353
 
@@ -355,7 +361,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
355
361
  super.requestChildFocus(child, focused);
356
362
  return;
357
363
  }
358
- mAndroidHWInputDeviceHelper.onFocusChanged(focused);
364
+ ReactContext context = getCurrentReactContext();
365
+ if (context != null) {
366
+ mAndroidHWInputDeviceHelper.onFocusChanged(focused, context);
367
+ }
359
368
  super.requestChildFocus(child, focused);
360
369
  }
361
370
 
@@ -196,8 +196,6 @@ public class FabricUIManager
196
196
 
197
197
  private boolean mDriveCxxAnimations = false;
198
198
 
199
- private boolean mDriveCxxNativeAnimated = ReactNativeFeatureFlags.cxxNativeAnimatedEnabled();
200
-
201
199
  private long mDispatchViewUpdatesTime = 0l;
202
200
  private long mCommitStartTime = 0l;
203
201
  private long mLayoutTime = 0l;
@@ -1478,7 +1476,8 @@ public class FabricUIManager
1478
1476
  // There is a race condition here between getting/setting
1479
1477
  // `mDriveCxxAnimations` which shouldn't matter; it's safe to call
1480
1478
  // the mBinding method, unless mBinding has gone away.
1481
- if ((mDriveCxxAnimations || mDriveCxxNativeAnimated) && mBinding != null) {
1479
+ if ((mDriveCxxAnimations || ReactNativeFeatureFlags.cxxNativeAnimatedEnabled())
1480
+ && mBinding != null) {
1482
1481
  mBinding.driveCxxAnimations();
1483
1482
  }
1484
1483
 
@@ -15,6 +15,6 @@ public object ReactNativeVersion {
15
15
  "major" to 0,
16
16
  "minor" to 82,
17
17
  "patch" to 0,
18
- "prerelease" to "nightly-20250728-869a976a5"
18
+ "prerelease" to "nightly-20250729-e17e3e3f3"
19
19
  )
20
20
  }
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 82;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "nightly-20250728-869a976a5";
25
+ std::string_view Prerelease = "nightly-20250729-e17e3e3f3";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -34,20 +34,23 @@ inline bool shouldIgnoreHermesFrame(
34
34
  RuntimeSamplingProfile::SampleCallStackFrame convertNativeHermesFrame(
35
35
  const fhsp::ProfileSampleCallStackNativeFunctionFrame& frame) {
36
36
  return RuntimeSamplingProfile::SampleCallStackFrame{
37
- RuntimeSamplingProfile::SampleCallStackFrame::Kind::NativeFunction,
38
- FALLBACK_SCRIPT_ID, // JavaScript Runtime defines the implementation
39
- // for native function, no script ID to reference.
40
- frame.getFunctionName(),
37
+ .kind =
38
+ RuntimeSamplingProfile::SampleCallStackFrame::Kind::NativeFunction,
39
+ .scriptId =
40
+ FALLBACK_SCRIPT_ID, // JavaScript Runtime defines the implementation
41
+ // for native function, no script ID to reference.
42
+ .functionName = frame.getFunctionName(),
41
43
  };
42
44
  }
43
45
 
44
46
  RuntimeSamplingProfile::SampleCallStackFrame convertHostFunctionHermesFrame(
45
47
  const fhsp::ProfileSampleCallStackHostFunctionFrame& frame) {
46
48
  return RuntimeSamplingProfile::SampleCallStackFrame{
47
- RuntimeSamplingProfile::SampleCallStackFrame::Kind::HostFunction,
48
- FALLBACK_SCRIPT_ID, // JavaScript Runtime defines the implementation
49
- // for host function, no script ID to reference.
50
- frame.getFunctionName(),
49
+ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::HostFunction,
50
+ .scriptId =
51
+ FALLBACK_SCRIPT_ID, // JavaScript Runtime defines the implementation
52
+ // for host function, no script ID to reference.
53
+ .functionName = frame.getFunctionName(),
51
54
  };
52
55
  }
53
56
 
@@ -56,10 +59,11 @@ RuntimeSamplingProfile::SampleCallStackFrame convertSuspendHermesFrame(
56
59
  if (frame.getSuspendFrameKind() ==
57
60
  fhsp::ProfileSampleCallStackSuspendFrame::SuspendFrameKind::GC) {
58
61
  return RuntimeSamplingProfile::SampleCallStackFrame{
59
- RuntimeSamplingProfile::SampleCallStackFrame::Kind::GarbageCollector,
60
- FALLBACK_SCRIPT_ID, // GC frames are part of the VM, no script ID to
61
- // reference.
62
- GARBAGE_COLLECTOR_FRAME_NAME,
62
+ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::
63
+ GarbageCollector,
64
+ .scriptId = FALLBACK_SCRIPT_ID, // GC frames are part of the VM, no
65
+ // script ID to reference.
66
+ .functionName = GARBAGE_COLLECTOR_FRAME_NAME,
63
67
  };
64
68
  }
65
69
 
@@ -71,18 +75,18 @@ RuntimeSamplingProfile::SampleCallStackFrame convertSuspendHermesFrame(
71
75
  RuntimeSamplingProfile::SampleCallStackFrame convertJSFunctionHermesFrame(
72
76
  const fhsp::ProfileSampleCallStackJSFunctionFrame& frame) {
73
77
  return RuntimeSamplingProfile::SampleCallStackFrame{
74
- RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
75
- frame.getScriptId(),
76
- frame.getFunctionName(),
77
- frame.hasScriptUrl()
78
+ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction,
79
+ .scriptId = frame.getScriptId(),
80
+ .functionName = frame.getFunctionName(),
81
+ .scriptURL = frame.hasScriptUrl()
78
82
  ? std::optional<std::string_view>{frame.getScriptUrl()}
79
83
  : std::nullopt,
80
- frame.hasFunctionLineNumber()
84
+ .lineNumber = frame.hasFunctionLineNumber()
81
85
  ? std::optional<uint32_t>{frame.getFunctionLineNumber() - 1}
82
86
  // Hermes VM keeps line numbers as 1-based. Convert
83
87
  // to 0-based.
84
88
  : std::nullopt,
85
- frame.hasFunctionColumnNumber()
89
+ .columnNumber = frame.hasFunctionColumnNumber()
86
90
  ? std::optional<uint32_t>{frame.getFunctionColumnNumber() - 1}
87
91
  // Hermes VM keeps column numbers as 1-based. Convert to
88
92
  // 0-based.
@@ -1877,7 +1877,9 @@ TEST_P(JSITest, CastInterface) {
1877
1877
  auto randomUuid = UUID{0xf2cd96cf, 0x455e, 0x42d9, 0x850a, 0x13e2cde59b8b};
1878
1878
  auto ptr = rd.castInterface(randomUuid);
1879
1879
 
1880
- EXPECT_EQ(ptr, nullptr);
1880
+ // Use == instead of EXPECT_EQ to avoid ambiguous operator usage due to the
1881
+ // type of 'ptr'.
1882
+ EXPECT_TRUE(ptr == nullptr);
1881
1883
  }
1882
1884
 
1883
1885
  INSTANTIATE_TEST_CASE_P(
@@ -172,7 +172,9 @@ tracing::InstanceTracingProfile InstanceAgent::collectTracingProfile() {
172
172
  tracing::RuntimeSamplingProfile runtimeSamplingProfile =
173
173
  runtimeAgent_->collectSamplingProfile();
174
174
 
175
- return tracing::InstanceTracingProfile{std::move(runtimeSamplingProfile)};
175
+ return tracing::InstanceTracingProfile{
176
+ .runtimeSamplingProfile = std::move(runtimeSamplingProfile),
177
+ };
176
178
  }
177
179
 
178
180
  } // namespace facebook::react::jsinspector_modern
@@ -102,10 +102,10 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
102
102
  // Send response to Tracing.end request.
103
103
  frontendChannel_(cdp::jsonResult(req.id));
104
104
 
105
- auto dataCollectedCallback = [this](const folly::dynamic& eventsChunk) {
105
+ auto dataCollectedCallback = [this](folly::dynamic&& eventsChunk) {
106
106
  frontendChannel_(cdp::jsonNotification(
107
107
  "Tracing.dataCollected",
108
- folly::dynamic::object("value", eventsChunk)));
108
+ folly::dynamic::object("value", std::move(eventsChunk))));
109
109
  };
110
110
  performanceTracer.collectEvents(
111
111
  dataCollectedCallback, TRACE_EVENT_CHUNK_SIZE);
@@ -114,8 +114,9 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
114
114
  performanceTracer,
115
115
  dataCollectedCallback,
116
116
  PROFILE_TRACE_EVENT_CHUNK_SIZE);
117
+ auto tracingProfile = instanceAgent_->collectTracingProfile();
117
118
  serializer.serializeAndNotify(
118
- instanceAgent_->collectTracingProfile().getRuntimeSamplingProfile(),
119
+ std::move(tracingProfile.runtimeSamplingProfile),
119
120
  instanceTracingStartTimestamp_);
120
121
 
121
122
  frontendChannel_(cdp::jsonNotification(
@@ -13,15 +13,7 @@ namespace facebook::react::jsinspector_modern::tracing {
13
13
 
14
14
  struct InstanceTracingProfile {
15
15
  public:
16
- explicit InstanceTracingProfile(RuntimeSamplingProfile runtimeSamplingProfile)
17
- : runtimeSamplingProfile_(std::move(runtimeSamplingProfile)) {}
18
-
19
- const RuntimeSamplingProfile& getRuntimeSamplingProfile() const {
20
- return runtimeSamplingProfile_;
21
- }
22
-
23
- private:
24
- RuntimeSamplingProfile runtimeSamplingProfile_;
16
+ RuntimeSamplingProfile runtimeSamplingProfile;
25
17
  };
26
18
 
27
19
  } // namespace facebook::react::jsinspector_modern::tracing
@@ -7,13 +7,13 @@
7
7
 
8
8
  #include "PerformanceTracer.h"
9
9
  #include "Timing.h"
10
+ #include "TraceEventSerializer.h"
10
11
 
11
12
  #include <oscompat/OSCompat.h>
12
13
  #include <react/timing/primitives.h>
13
14
 
14
15
  #include <folly/json.h>
15
16
 
16
- #include <array>
17
17
  #include <mutex>
18
18
 
19
19
  namespace facebook::react::jsinspector_modern::tracing {
@@ -83,8 +83,7 @@ bool PerformanceTracer::stopTracing() {
83
83
  }
84
84
 
85
85
  void PerformanceTracer::collectEvents(
86
- const std::function<void(const folly::dynamic& eventsChunk)>&
87
- resultCallback,
86
+ const std::function<void(folly::dynamic&& eventsChunk)>& resultCallback,
88
87
  uint16_t chunkSize) {
89
88
  std::vector<TraceEvent> localBuffer;
90
89
  {
@@ -99,15 +98,16 @@ void PerformanceTracer::collectEvents(
99
98
  auto serializedTraceEvents = folly::dynamic::array();
100
99
  for (auto&& event : localBuffer) {
101
100
  // Emit trace events
102
- serializedTraceEvents.push_back(serializeTraceEvent(std::move(event)));
101
+ serializedTraceEvents.push_back(
102
+ TraceEventSerializer::serialize(std::move(event)));
103
103
 
104
104
  if (serializedTraceEvents.size() == chunkSize) {
105
- resultCallback(serializedTraceEvents);
105
+ resultCallback(std::move(serializedTraceEvents));
106
106
  serializedTraceEvents = folly::dynamic::array();
107
107
  }
108
108
  }
109
109
  if (!serializedTraceEvents.empty()) {
110
- resultCallback(serializedTraceEvents);
110
+ resultCallback(std::move(serializedTraceEvents));
111
111
  }
112
112
  }
113
113
 
@@ -126,7 +126,7 @@ folly::dynamic PerformanceTracer::collectEvents(uint16_t chunkSize) {
126
126
  auto chunk = folly::dynamic::array();
127
127
  chunk.reserve(chunkSize);
128
128
  for (auto&& event : localBuffer) {
129
- chunk.push_back(serializeTraceEvent(std::move(event)));
129
+ chunk.push_back(TraceEventSerializer::serialize(std::move(event)));
130
130
 
131
131
  if (chunk.size() == chunkSize) {
132
132
  chunks.push_back(std::move(chunk));
@@ -381,7 +381,7 @@ folly::dynamic PerformanceTracer::getSerializedRuntimeProfileTraceEvent(
381
381
  HighResTimeStamp profileTimestamp) {
382
382
  // CDT prioritizes event timestamp over startTime metadata field.
383
383
  // https://fburl.com/lo764pf4
384
- return serializeTraceEvent(TraceEvent{
384
+ return TraceEventSerializer::serialize(TraceEvent{
385
385
  .id = profileId,
386
386
  .name = "Profile",
387
387
  .cat = "disabled-by-default-v8.cpu_profiler",
@@ -401,8 +401,8 @@ folly::dynamic PerformanceTracer::getSerializedRuntimeProfileChunkTraceEvent(
401
401
  uint16_t profileId,
402
402
  uint64_t threadId,
403
403
  HighResTimeStamp chunkTimestamp,
404
- const tracing::TraceEventProfileChunk& traceEventProfileChunk) {
405
- return serializeTraceEvent(TraceEvent{
404
+ tracing::TraceEventProfileChunk&& traceEventProfileChunk) {
405
+ return TraceEventSerializer::serialize(TraceEvent{
406
406
  .id = profileId,
407
407
  .name = "ProfileChunk",
408
408
  .cat = "disabled-by-default-v8.cpu_profiler",
@@ -410,32 +410,11 @@ folly::dynamic PerformanceTracer::getSerializedRuntimeProfileChunkTraceEvent(
410
410
  .ts = chunkTimestamp,
411
411
  .pid = processId_,
412
412
  .tid = threadId,
413
- .args =
414
- folly::dynamic::object("data", traceEventProfileChunk.toDynamic()),
413
+ .args = folly::dynamic::object(
414
+ "data",
415
+ TraceEventSerializer::serializeProfileChunk(
416
+ std::move(traceEventProfileChunk))),
415
417
  });
416
418
  }
417
419
 
418
- folly::dynamic PerformanceTracer::serializeTraceEvent(
419
- TraceEvent&& event) const {
420
- folly::dynamic result = folly::dynamic::object;
421
-
422
- if (event.id.has_value()) {
423
- std::array<char, 16> buffer{};
424
- snprintf(buffer.data(), buffer.size(), "0x%x", event.id.value());
425
- result["id"] = buffer.data();
426
- }
427
- result["name"] = std::move(event.name);
428
- result["cat"] = std::move(event.cat);
429
- result["ph"] = std::string(1, event.ph);
430
- result["ts"] = highResTimeStampToTracingClockTimeStamp(event.ts);
431
- result["pid"] = event.pid;
432
- result["tid"] = event.tid;
433
- result["args"] = std::move(event.args);
434
- if (event.dur.has_value()) {
435
- result["dur"] = highResDurationToTracingClockDuration(event.dur.value());
436
- }
437
-
438
- return result;
439
- }
440
-
441
420
  } // namespace facebook::react::jsinspector_modern::tracing
@@ -56,8 +56,7 @@ class PerformanceTracer {
56
56
  * Flush out buffered CDP Trace Events using the given callback.
57
57
  */
58
58
  void collectEvents(
59
- const std::function<void(const folly::dynamic& eventsChunk)>&
60
- resultCallback,
59
+ const std::function<void(folly::dynamic&& eventsChunk)>& resultCallback,
61
60
  uint16_t chunkSize);
62
61
 
63
62
  /**
@@ -149,7 +148,7 @@ class PerformanceTracer {
149
148
  uint16_t profileId,
150
149
  uint64_t threadId,
151
150
  HighResTimeStamp chunkTimestamp,
152
- const TraceEventProfileChunk& traceEventProfileChunk);
151
+ TraceEventProfileChunk&& traceEventProfileChunk);
153
152
 
154
153
  private:
155
154
  PerformanceTracer();
@@ -157,14 +156,6 @@ class PerformanceTracer {
157
156
  PerformanceTracer& operator=(const PerformanceTracer&) = delete;
158
157
  ~PerformanceTracer() = default;
159
158
 
160
- /**
161
- * Serialize a TraceEvent into a folly::dynamic object.
162
- * \param event rvalue reference to the TraceEvent object.
163
- * \return folly::dynamic object that represents a serialized into JSON Trace
164
- * Event for CDP.
165
- */
166
- folly::dynamic serializeTraceEvent(TraceEvent&& event) const;
167
-
168
159
  const uint64_t processId_;
169
160
 
170
161
  /**