Skip to content

Commit 621592d

Browse files
Donald Webstermeta-codesync[bot]
authored andcommitted
Revert D95817614: Add performance track for React Native renderer
Differential Revision: D95817614 Original commit changeset: 4d6be2732c64 Original Phabricator Diff: D95817614 fbshipit-source-id: 7287ae7c98c78017b2132ede70dbee0a1d3b8d47
1 parent 29bc8f1 commit 621592d

File tree

10 files changed

+67
-167
lines changed

10 files changed

+67
-167
lines changed

packages/react-native/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ let reactFabric = RNTarget(
463463
"components/virtualview",
464464
"components/root/tests",
465465
],
466-
dependencies: [.reactNativeDependencies, .reactJsiExecutor, .rctTypesafety, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .reactRendererDebug, .reactGraphics, .yoga, .reactJsInspectorTracing],
466+
dependencies: [.reactNativeDependencies, .reactJsiExecutor, .rctTypesafety, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .reactRendererDebug, .reactGraphics, .yoga],
467467
sources: ["animated", "animationbackend", "animations", "attributedstring", "core", "componentregistry", "componentregistry/native", "components/root", "components/view", "components/view/platform/cxx", "components/scrollview", "components/scrollview/platform/cxx", "components/scrollview/platform/ios", "components/legacyviewmanagerinterop", "components/legacyviewmanagerinterop/platform/ios", "dom", "scheduler", "mounting", "observers/events", "observers/intersection", "observers/mutation", "telemetry", "consistency", "leakchecker", "uimanager", "uimanager/consistency", "viewtransition"]
468468
)
469469

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,6 @@ public final class com/facebook/react/soloader/OpenSourceMergedSoMapping : com/f
31143114
public final fun libreact_devsupportjni_so ()I
31153115
public final fun libreact_featureflagsjni_so ()I
31163116
public final fun libreact_newarchdefaults_so ()I
3117-
public final fun libreact_tracingjni_so ()I
31183117
public final fun libreactnative_so ()I
31193118
public final fun libreactnativeblob_so ()I
31203119
public final fun libreactnativejni_common_so ()I

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt

Lines changed: 64 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.facebook.react.fabric.FabricUIManager
2121
import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem
2222
import com.facebook.react.fabric.mounting.mountitems.MountItem
2323
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
24-
import com.facebook.react.internal.tracing.PerformanceTracer
2524
import com.facebook.systrace.Systrace
2625
import java.util.Queue
2726
import java.util.concurrent.ConcurrentLinkedQueue
@@ -202,16 +201,9 @@ internal class MountItemDispatcher(
202201
"MountItemDispatcher::mountViews viewCommandMountItems",
203202
)
204203

205-
PerformanceTracer.trace(
206-
"view commands",
207-
"Renderer",
208-
"\u269b Native",
209-
{ ->
210-
for (command in commands) {
211-
dispatchViewCommand(command)
212-
}
213-
},
214-
)
204+
for (command in commands) {
205+
dispatchViewCommand(command)
206+
}
215207

216208
Systrace.endSection(Systrace.TRACE_TAG_REACT)
217209
}
@@ -223,21 +215,12 @@ internal class MountItemDispatcher(
223215
Systrace.TRACE_TAG_REACT,
224216
"MountItemDispatcher::mountViews preMountItems",
225217
)
226-
227-
PerformanceTracer.trace(
228-
"premount",
229-
"Renderer",
230-
"\u269b Native",
231-
{ ->
232-
for (preMountItem in preMountItems) {
233-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
234-
printMountItem(preMountItem, "dispatchMountItems: Executing preMountItem")
235-
}
236-
executeOrEnqueue(preMountItem)
237-
}
238-
},
239-
)
240-
218+
for (preMountItem in preMountItems) {
219+
if (ReactNativeFeatureFlags.enableFabricLogs()) {
220+
printMountItem(preMountItem, "dispatchMountItems: Executing preMountItem")
221+
}
222+
executeOrEnqueue(preMountItem)
223+
}
241224
Systrace.endSection(Systrace.TRACE_TAG_REACT)
242225
}
243226

@@ -246,56 +229,44 @@ internal class MountItemDispatcher(
246229
Systrace.TRACE_TAG_REACT,
247230
"MountItemDispatcher::mountViews mountItems to execute",
248231
)
232+
val batchedExecutionStartTime = SystemClock.uptimeMillis()
233+
234+
for (mountItem in items) {
235+
if (ReactNativeFeatureFlags.enableFabricLogs()) {
236+
printMountItem(mountItem, "dispatchMountItems: Executing mountItem")
237+
}
238+
239+
val command = mountItem as? DispatchCommandMountItem
240+
if (command != null) {
241+
dispatchViewCommand(command)
242+
continue
243+
}
249244

250-
PerformanceTracer.trace(
251-
"mount",
252-
"Renderer",
253-
"\u269b Native",
254-
{ ->
255-
val batchedExecutionStartTime = SystemClock.uptimeMillis()
256-
257-
for (mountItem in items) {
258-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
259-
printMountItem(mountItem, "dispatchMountItems: Executing mountItem")
260-
}
261-
262-
val command = mountItem as? DispatchCommandMountItem
263-
if (command != null) {
264-
dispatchViewCommand(command)
265-
continue
266-
}
267-
268-
try {
269-
executeOrEnqueue(mountItem)
270-
} catch (e: Throwable) {
271-
// If there's an exception, we want to log diagnostics in prod and rethrow.
272-
FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e)
273-
for (m in items) {
274-
if (m === mountItem) {
275-
// We want to mark the mount item that caused exception
276-
FLog.e(
277-
TAG,
278-
"dispatchMountItems: mountItem: next mountItem triggered exception!",
279-
)
280-
}
281-
printMountItem(m, "dispatchMountItems: mountItem")
282-
}
283-
284-
if (mountItem.getSurfaceId() != View.NO_ID) {
285-
mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
286-
}
287-
288-
if (ReactIgnorableMountingException.isIgnorable(e)) {
289-
ReactSoftExceptionLogger.logSoftException(TAG, e)
290-
} else {
291-
throw e
292-
}
293-
}
245+
try {
246+
executeOrEnqueue(mountItem)
247+
} catch (e: Throwable) {
248+
// If there's an exception, we want to log diagnostics in prod and rethrow.
249+
FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e)
250+
for (m in items) {
251+
if (m === mountItem) {
252+
// We want to mark the mount item that caused exception
253+
FLog.e(TAG, "dispatchMountItems: mountItem: next mountItem triggered exception!")
294254
}
295-
batchedExecutionTime += SystemClock.uptimeMillis() - batchedExecutionStartTime
296-
},
297-
)
255+
printMountItem(m, "dispatchMountItems: mountItem")
256+
}
257+
258+
if (mountItem.getSurfaceId() != View.NO_ID) {
259+
mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
260+
}
298261

262+
if (ReactIgnorableMountingException.isIgnorable(e)) {
263+
ReactSoftExceptionLogger.logSoftException(TAG, e)
264+
} else {
265+
throw e
266+
}
267+
}
268+
}
269+
batchedExecutionTime += SystemClock.uptimeMillis() - batchedExecutionStartTime
299270
Systrace.endSection(Systrace.TRACE_TAG_REACT)
300271
}
301272

@@ -326,34 +297,26 @@ internal class MountItemDispatcher(
326297
private fun dispatchPreMountItemsImpl(deadline: Long) {
327298
Systrace.beginSection(Systrace.TRACE_TAG_REACT, "MountItemDispatcher::premountViews")
328299

329-
PerformanceTracer.trace(
330-
"premount",
331-
"Renderer",
332-
"\u269b Native",
333-
{ ->
334-
// dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems
335-
// from
336-
// reentering during dispatchPreMountItems
337-
inDispatch = true
338-
339-
try {
340-
while (true) {
341-
if (System.nanoTime() > deadline) {
342-
break
343-
}
344-
345-
// If list is empty, `poll` will return null, or var will never be set
346-
val preMountItemToDispatch = preMountItems.poll() ?: break
347-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
348-
printMountItem(preMountItemToDispatch, "dispatchPreMountItems")
349-
}
350-
executeOrEnqueue(preMountItemToDispatch)
351-
}
352-
} finally {
353-
inDispatch = false
354-
}
355-
},
356-
)
300+
// dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems from
301+
// reentering during dispatchPreMountItems
302+
inDispatch = true
303+
304+
try {
305+
while (true) {
306+
if (System.nanoTime() > deadline) {
307+
break
308+
}
309+
310+
// If list is empty, `poll` will return null, or var will never be set
311+
val preMountItemToDispatch = preMountItems.poll() ?: break
312+
if (ReactNativeFeatureFlags.enableFabricLogs()) {
313+
printMountItem(preMountItemToDispatch, "dispatchPreMountItems")
314+
}
315+
executeOrEnqueue(preMountItemToDispatch)
316+
}
317+
} finally {
318+
inDispatch = false
319+
}
357320

358321
Systrace.endSection(Systrace.TRACE_TAG_REACT)
359322
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/tracing/PerformanceTracer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.facebook.soloader.SoLoader
2020
@DoNotStrip
2121
public object PerformanceTracer {
2222
init {
23-
SoLoader.loadLibrary("react_tracingjni")
23+
SoLoader.loadLibrary("react_performancetracerjni")
2424
}
2525

2626
public fun <T> trace(name: String, block: () -> T): T {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/soloader/OpenSourceMergedSoMapping.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {
2828
"react_devsupportjni",
2929
"react_featureflagsjni",
3030
"react_newarchdefaults",
31-
"react_tracingjni",
3231
"reactnativeblob",
3332
"reactnativejni",
3433
"reactnativejni_common",
@@ -58,7 +57,6 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {
5857
"react_devsupportjni" -> libreact_devsupportjni_so()
5958
"react_featureflagsjni" -> libreact_featureflagsjni_so()
6059
"react_newarchdefaults" -> libreact_newarchdefaults_so()
61-
"react_tracingjni" -> libreact_tracingjni_so()
6260
"reactnative" -> libreactnative_so()
6361
"reactnativeblob" -> libreactnativeblob_so()
6462
"reactnativejni" -> libreactnativejni_so()
@@ -90,8 +88,6 @@ public object OpenSourceMergedSoMapping : ExternalSoMapping {
9088

9189
public external fun libreact_newarchdefaults_so(): Int
9290

93-
public external fun libreact_tracingjni_so(): Int
94-
9591
public external fun libreactnative_so(): Int
9692

9793
public external fun libreactnativeblob_so(): Int

packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ add_react_android_subdir(src/main/jni/react/hermes/instrumentation/)
159159
add_react_android_subdir(src/main/jni/react/runtime/cxxreactpackage)
160160
add_react_android_subdir(src/main/jni/react/runtime/jni)
161161
add_react_android_subdir(src/main/jni/react/runtime/hermes/jni)
162-
add_react_android_subdir(src/main/jni/react/tracing)
163162
add_react_android_subdir(src/main/jni/react/devsupport)
164163

165164
# SoMerging Utils
@@ -232,7 +231,6 @@ add_library(reactnative
232231
$<TARGET_OBJECTS:react_renderer_uimanager>
233232
$<TARGET_OBJECTS:react_renderer_uimanager_consistency>
234233
$<TARGET_OBJECTS:react_renderer_viewtransition>
235-
$<TARGET_OBJECTS:react_tracingjni>
236234
$<TARGET_OBJECTS:react_utils>
237235
$<TARGET_OBJECTS:reactnativeblob>
238236
$<TARGET_OBJECTS:reactnativejni>
@@ -333,7 +331,6 @@ target_include_directories(reactnative
333331
$<TARGET_PROPERTY:react_renderer_uimanager,INTERFACE_INCLUDE_DIRECTORIES>
334332
$<TARGET_PROPERTY:react_renderer_uimanager_consistency,INTERFACE_INCLUDE_DIRECTORIES>
335333
$<TARGET_PROPERTY:react_renderer_viewtransition,INTERFACE_INCLUDE_DIRECTORIES>
336-
$<TARGET_PROPERTY:react_tracingjni,INTERFACE_INCLUDE_DIRECTORIES>
337334
$<TARGET_PROPERTY:react_utils,INTERFACE_INCLUDE_DIRECTORIES>
338335
$<TARGET_PROPERTY:reactnativeblob,INTERFACE_INCLUDE_DIRECTORIES>
339336
$<TARGET_PROPERTY:reactnativejni,INTERFACE_INCLUDE_DIRECTORIES>

packages/react-native/ReactAndroid/src/main/jni/react/tracing/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/react-native/ReactCommon/React-Fabric.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ Pod::Spec.new do |s|
173173
end
174174

175175
s.subspec "mounting" do |ss|
176-
ss.dependency "React-jsinspectortracing"
177176
ss.source_files = podspec_sources("react/renderer/mounting/**/*.{m,mm,cpp,h}", "react/renderer/mounting/**/*.h")
178177
ss.exclude_files = "react/renderer/mounting/tests"
179178
ss.header_dir = "react/renderer/mounting"

packages/react-native/ReactCommon/react/renderer/mounting/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ target_link_libraries(react_renderer_mounting
2222
glog
2323
glog_init
2424
jsi
25-
jsinspector_tracing
2625
react_debug
2726
react_renderer_core
2827
react_renderer_debug

packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "ShadowTree.h"
99

1010
#include <cxxreact/TraceSection.h>
11-
#include <jsinspector-modern/tracing/PerformanceTracerSection.h>
1211
#include <react/debug/react_native_assert.h>
1312
#include <react/renderer/components/root/RootComponentDescriptor.h>
1413
#include <react/renderer/components/view/ViewShadowNode.h>
@@ -25,19 +24,6 @@ namespace facebook::react {
2524

2625
namespace {
2726
const int MAX_COMMIT_ATTEMPTS_BEFORE_LOCKING = 3;
28-
29-
std::string getShadowTreeCommitSourceName(ShadowTreeCommitSource source) {
30-
switch (source) {
31-
case ShadowTreeCommitSource::Unknown:
32-
return "Unknown";
33-
case ShadowTreeCommitSource::React:
34-
return "React";
35-
case ShadowTreeCommitSource::AnimationEndSync:
36-
return "AnimationEndSync";
37-
case ShadowTreeCommitSource::ReactRevisionMerge:
38-
return "ReactRevisionMerge";
39-
}
40-
}
4127
} // namespace
4228

4329
using CommitStatus = ShadowTree::CommitStatus;
@@ -330,13 +316,6 @@ CommitStatus ShadowTree::tryCommit(
330316
const ShadowTreeCommitTransaction& transaction,
331317
const CommitOptions& commitOptions) const {
332318
TraceSection s("ShadowTree::commit");
333-
jsinspector_modern::tracing::PerformanceTracerSection s1(
334-
"commit",
335-
"Renderer",
336-
"\u269b Native",
337-
nullptr,
338-
"source",
339-
getShadowTreeCommitSourceName(commitOptions.source));
340319

341320
auto isReactBranch = ReactNativeFeatureFlags::enableFabricCommitBranching() &&
342321
commitOptions.source == CommitSource::React;
@@ -403,11 +382,7 @@ CommitStatus ShadowTree::tryCommit(
403382

404383
telemetry.willLayout();
405384
telemetry.setAsThreadLocal();
406-
{
407-
jsinspector_modern::tracing::PerformanceTracerSection s2(
408-
"layout", "Renderer", "\u269b Native");
409-
newRootShadowNode->layoutIfNeeded(&affectedLayoutableNodes);
410-
}
385+
newRootShadowNode->layoutIfNeeded(&affectedLayoutableNodes);
411386
telemetry.unsetAsThreadLocal();
412387
telemetry.didLayout(static_cast<int>(affectedLayoutableNodes.size()));
413388

0 commit comments

Comments
 (0)