From d0ab69791bfb31ed0aba537a69a5fcefae52cc67 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 10 Apr 2025 10:06:47 -0700 Subject: [PATCH] Align all Systrace markers on TRACE_TAG_REACT Summary: We currently have a high granularity of different React Native systrace markers. These different markers are not consistently applied and we only enable a subset of them by default in our tracing workflows. As we migrate more and more tracing to Perfetto the tags also become less relevant and will be replaced by Perfetto categories and tracks in the future. This stack aims to simplify this setup by reducing all systrace tags to single TRACE_TAG_REACT. Changelog: [Internal] Reviewed By: rshest Differential Revision: D72672912 fbshipit-source-id: 1b6b14fc4ef6d6830bba41d7977f277d63ff5117 --- .../Libraries/BatchedBridge/MessageQueue.js | 4 +- .../Libraries/Performance/Systrace.js | 14 ++--- .../React/CxxModule/RCTNativeModule.mm | 2 +- .../facebook/react/CoreModulesPackage.java | 4 +- .../com/facebook/react/LazyReactPackage.java | 6 +- .../facebook/react/ReactActivityDelegate.java | 2 +- .../facebook/react/ReactInstanceManager.java | 60 +++++++++---------- .../com/facebook/react/ReactRootView.java | 18 +++--- .../facebook/react/bridge/BridgeSoLoader.kt | 4 -- .../react/bridge/CatalystInstanceImpl.java | 16 +++-- .../react/bridge/JavaMethodWrapper.java | 10 ++-- .../react/bridge/JavaModuleWrapper.java | 18 +++--- .../facebook/react/bridge/ModuleHolder.java | 10 ++-- .../react/bridge/NativeModuleRegistry.java | 9 ++- .../facebook/react/fabric/FabricSoLoader.kt | 4 +- .../fabric/FabricUIManagerProviderImpl.kt | 17 ++---- .../react/fabric/events/FabricEventEmitter.kt | 5 +- .../fabric/mounting/MountItemDispatcher.java | 19 +++--- .../mounting/SurfaceMountingManager.java | 4 +- .../mountitems/IntBufferBatchMountItem.java | 9 ++- .../react/internal/SystraceSection.kt | 4 +- .../modules/fresco/SystraceRequestListener.kt | 36 +++++------ .../facebook/react/runtime/ReactInstance.java | 43 ++++++------- .../react/runtime/ReactSurfaceView.kt | 4 +- .../uimanager/NativeViewHierarchyManager.java | 9 ++- .../react/uimanager/UIImplementation.java | 23 ++++--- .../react/uimanager/UIManagerModule.java | 20 +++---- .../react/uimanager/UIViewOperationQueue.java | 40 ++++++------- .../uimanager/events/EventDispatcherImpl.java | 17 +++--- .../uimanager/events/FabricEventDispatcher.kt | 12 ++-- .../react/uimanager/events/TouchesHelper.kt | 5 +- .../scroll/ReactHorizontalScrollView.java | 10 ++-- .../react/views/scroll/ReactScrollView.java | 9 ++- .../java/com/facebook/systrace/Systrace.kt | 6 +- .../main/jni/react/jni/JavaModuleWrapper.cpp | 2 +- .../src/main/jni/react/jni/MethodInvoker.cpp | 2 +- .../ReactCommon/cxxreact/CxxNativeModule.cpp | 2 +- .../ReactCommon/cxxreact/NativeToJsBridge.cpp | 12 ++-- .../ReactCommon/cxxreact/TraceSection.h | 2 +- .../reactperflogger/ReactPerfettoLogger.cpp | 11 ++-- 40 files changed, 226 insertions(+), 278 deletions(-) diff --git a/packages/react-native/Libraries/BatchedBridge/MessageQueue.js b/packages/react-native/Libraries/BatchedBridge/MessageQueue.js index 43da696e3c3..298d2e9d7e8 100644 --- a/packages/react-native/Libraries/BatchedBridge/MessageQueue.js +++ b/packages/react-native/Libraries/BatchedBridge/MessageQueue.js @@ -35,7 +35,7 @@ const PARAMS = 2; const MIN_TIME_BETWEEN_FLUSHES_MS = 5; // eslint-disable-next-line no-bitwise -const TRACE_TAG_REACT_APPS = 1 << 17; +const TRACE_TAG_REACT = 1 << 13; const DEBUG_INFO_LIMIT = 32; @@ -228,7 +228,7 @@ class MessageQueue { if (__DEV__) { global.nativeTraceBeginAsyncFlow && global.nativeTraceBeginAsyncFlow( - TRACE_TAG_REACT_APPS, + TRACE_TAG_REACT, 'native', this._callID, ); diff --git a/packages/react-native/Libraries/Performance/Systrace.js b/packages/react-native/Libraries/Performance/Systrace.js index 581db4b375d..4e1be11ce6f 100644 --- a/packages/react-native/Libraries/Performance/Systrace.js +++ b/packages/react-native/Libraries/Performance/Systrace.js @@ -10,7 +10,7 @@ import typeof * as SystraceModule from './Systrace'; -const TRACE_TAG_REACT_APPS = 1 << 17; // eslint-disable-line no-bitwise +const TRACE_TAG_REACT = 1 << 13; // eslint-disable-line no-bitwise let _asyncCookie = 0; @@ -32,7 +32,7 @@ type EventArgs = ?{[string]: string}; */ export function isEnabled(): boolean { return global.nativeTraceIsTracing - ? global.nativeTraceIsTracing(TRACE_TAG_REACT_APPS) + ? global.nativeTraceIsTracing(TRACE_TAG_REACT) : Boolean(global.__RCTProfileIsProfiling); } @@ -52,7 +52,7 @@ export function beginEvent(eventName: EventName, args?: EventArgs): void { if (isEnabled()) { const eventNameString = typeof eventName === 'function' ? eventName() : eventName; - global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, eventNameString, args); + global.nativeTraceBeginSection(TRACE_TAG_REACT, eventNameString, args); } } @@ -61,7 +61,7 @@ export function beginEvent(eventName: EventName, args?: EventArgs): void { */ export function endEvent(args?: EventArgs): void { if (isEnabled()) { - global.nativeTraceEndSection(TRACE_TAG_REACT_APPS, args); + global.nativeTraceEndSection(TRACE_TAG_REACT, args); } } @@ -80,7 +80,7 @@ export function beginAsyncEvent( const eventNameString = typeof eventName === 'function' ? eventName() : eventName; global.nativeTraceBeginAsyncSection( - TRACE_TAG_REACT_APPS, + TRACE_TAG_REACT, eventNameString, cookie, args, @@ -102,7 +102,7 @@ export function endAsyncEvent( const eventNameString = typeof eventName === 'function' ? eventName() : eventName; global.nativeTraceEndAsyncSection( - TRACE_TAG_REACT_APPS, + TRACE_TAG_REACT, eventNameString, cookie, args, @@ -118,7 +118,7 @@ export function counterEvent(eventName: EventName, value: number): void { const eventNameString = typeof eventName === 'function' ? eventName() : eventName; global.nativeTraceCounter && - global.nativeTraceCounter(TRACE_TAG_REACT_APPS, eventNameString, value); + global.nativeTraceCounter(TRACE_TAG_REACT, eventNameString, value); } } diff --git a/packages/react-native/React/CxxModule/RCTNativeModule.mm b/packages/react-native/React/CxxModule/RCTNativeModule.mm index 3f86bc87cb1..5e939154045 100644 --- a/packages/react-native/React/CxxModule/RCTNativeModule.mm +++ b/packages/react-native/React/CxxModule/RCTNativeModule.mm @@ -104,7 +104,7 @@ void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &¶ms, int dispatch_block_t block = [weakBridge, weakModuleData, methodId, params = std::move(params), callId, isSyncModule] { #ifdef WITH_FBSYSTRACE if (callId != -1) { - fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId); + fbsystrace_end_async_flow(TRACE_TAG_REACT, "native", callId); } #else (void)(callId); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 429ca74d915..c8821178be0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -180,7 +180,7 @@ class CoreModulesPackage extends BaseReactPackage implements ReactPackageLogger private UIManagerModule createUIManager(final ReactApplicationContext reactContext) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START); - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "createUIManagerModule"); try { if (mLazyViewManagersEnabled) { ViewManagerResolver resolver = @@ -205,7 +205,7 @@ class CoreModulesPackage extends BaseReactPackage implements ReactPackageLogger mMinTimeLeftInFrameForNonBatchedOperationMs); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java index e56f2092ab1..2f1d9567b88 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java @@ -7,7 +7,7 @@ package com.facebook.react; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.ModuleHolder; @@ -105,13 +105,13 @@ public abstract class LazyReactPackage implements ReactPackage { List modules = new ArrayList<>(); for (ModuleSpec holder : getNativeModules(reactContext)) { NativeModule nativeModule; - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule").flush(); + SystraceMessage.beginSection(TRACE_TAG_REACT, "createNativeModule").flush(); ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_START, holder.getName()); try { nativeModule = holder.getProvider().get(); } finally { ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END); - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } modules.add(nativeModule); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index 22911bebf76..cf38636f1e0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -116,7 +116,7 @@ public class ReactActivityDelegate { public void onCreate(Bundle savedInstanceState) { Systrace.traceSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "ReactActivityDelegate.onCreate::init", () -> { String mainComponentName = getMainComponentName(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index d9efcc5f144..4b9484dea8f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -28,9 +28,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START; import static com.facebook.react.bridge.ReactMarkerConstants.VM_INIT; import static com.facebook.react.uimanager.common.UIManagerType.FABRIC; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_APPS; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JS_VM_CALLS; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import android.app.Activity; import android.content.Context; @@ -276,8 +274,7 @@ public class ReactInstanceManager { mUseDeveloperSupport = useDeveloperSupport; mRequireActivity = requireActivity; mKeepActivity = keepActivity; - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.initDevSupportManager"); + Systrace.beginSection(TRACE_TAG_REACT, "ReactInstanceManager.initDevSupportManager"); mDevSupportManager = devSupportManagerFactory.create( applicationContext, @@ -291,7 +288,7 @@ public class ReactInstanceManager { surfaceDelegateFactory, devLoadingViewManager, pausedInDebuggerOverlayManager); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); mBridgeIdleDebugListener = bridgeIdleDebugListener; mLifecycleState = initialLifecycleState; mMemoryPressureRouter = new MemoryPressureRouter(applicationContext); @@ -486,7 +483,7 @@ public class ReactInstanceManager { if (mUseDeveloperSupport && mJSMainModulePath != null) { final DeveloperSettings devSettings = mDevSupportManager.getDevSettings(); - if (!Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) { + if (!Systrace.isTracing(TRACE_TAG_REACT)) { if (mBundleLoader == null) { mDevSupportManager.handleReloadJS(); } else { @@ -1012,7 +1009,7 @@ public class ReactInstanceManager { public List getOrCreateViewManagers( ReactApplicationContext catalystApplicationContext) { ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers"); + Systrace.beginSection(TRACE_TAG_REACT, "createAllViewManagers"); try { if (mViewManagers == null) { synchronized (mPackages) { @@ -1028,7 +1025,7 @@ public class ReactInstanceManager { } return mViewManagers; } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END); } } @@ -1058,7 +1055,7 @@ public class ReactInstanceManager { } public Collection getViewManagerNames() { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerNames"); + Systrace.beginSection(TRACE_TAG_REACT, "ReactInstanceManager.getViewManagerNames"); try { Collection viewManagerNames = mViewManagerNames; if (viewManagerNames != null) { @@ -1077,8 +1074,7 @@ public class ReactInstanceManager { if (mViewManagerNames == null) { Set uniqueNames = new HashSet<>(); for (ReactPackage reactPackage : mPackages) { - SystraceMessage.beginSection( - TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.getViewManagerName") + SystraceMessage.beginSection(TRACE_TAG_REACT, "ReactInstanceManager.getViewManagerName") .arg("Package", reactPackage.getClass().getSimpleName()) .flush(); if (reactPackage instanceof ViewManagerOnDemandReactPackage) { @@ -1094,14 +1090,14 @@ public class ReactInstanceManager { + " loaded", reactPackage.getClass().getSimpleName()); } - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } mViewManagerNames = uniqueNames; } return mViewManagerNames; } } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } @@ -1265,7 +1261,7 @@ public class ReactInstanceManager { FLog.d(ReactConstants.TAG, "ReactInstanceManager.setupReactContext()"); ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END); ReactMarker.logMarker(SETUP_REACT_CONTEXT_START); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext"); + Systrace.beginSection(TRACE_TAG_REACT, "setupReactContext"); synchronized (mAttachedReactRoots) { synchronized (mReactContextLock) { mCurrentReactContext = Assertions.assertNotNull(reactContext); @@ -1315,7 +1311,7 @@ public class ReactInstanceManager { reactContext.runOnNativeModulesQueueThread( () -> Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT)); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); ReactMarker.logMarker(SETUP_REACT_CONTEXT_END); // Mark end of bridge loading ReactMarker.logMarker(ReactMarkerConstants.REACT_BRIDGE_LOADING_END); @@ -1328,7 +1324,7 @@ public class ReactInstanceManager { return; } - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance"); + Systrace.beginSection(TRACE_TAG_REACT, "attachRootViewToInstance"); @Nullable UIManager uiManager = @@ -1366,15 +1362,14 @@ public class ReactInstanceManager { reactRoot.runApplication(); } - Systrace.beginAsyncSection( - TRACE_TAG_REACT_JAVA_BRIDGE, "pre_rootView.onAttachedToReactInstance", rootTag); + Systrace.beginAsyncSection(TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag); UiThreadUtil.runOnUiThread( () -> { Systrace.endAsyncSection( - TRACE_TAG_REACT_JAVA_BRIDGE, "pre_rootView.onAttachedToReactInstance", rootTag); + TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag); reactRoot.onStage(ReactStage.ON_ATTACH_TO_INSTANCE); }); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactContext) { @@ -1467,12 +1462,12 @@ public class ReactInstanceManager { ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_START); // CREATE_CATALYST_INSTANCE_END is in JSCExecutor.cpp - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstance"); + Systrace.beginSection(TRACE_TAG_REACT, "createCatalystInstance"); final CatalystInstance catalystInstance; try { catalystInstance = catalystInstanceBuilder.build(); } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_END); } @@ -1520,15 +1515,14 @@ public class ReactInstanceManager { if (mBridgeIdleDebugListener != null) { catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener); } - if (BuildConfig.ENABLE_PERFETTO - || Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) { + if (BuildConfig.ENABLE_PERFETTO || Systrace.isTracing(TRACE_TAG_REACT)) { catalystInstance.setGlobalVariable("__RCTProfileIsProfiling", "true"); } ReactMarker.logMarker(ReactMarkerConstants.PRE_RUN_JS_BUNDLE_START); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); + Systrace.beginSection(TRACE_TAG_REACT, "runJSBundle"); catalystInstance.runJSBundle(); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); return reactContext; } @@ -1542,23 +1536,23 @@ public class ReactInstanceManager { synchronized (mPackages) { for (ReactPackage reactPackage : packages) { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAndProcessCustomReactPackage"); + Systrace.beginSection(TRACE_TAG_REACT, "createAndProcessCustomReactPackage"); try { processPackage(reactPackage, nativeModuleRegistryBuilder); } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } } ReactMarker.logMarker(PROCESS_PACKAGES_END); ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_START); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "buildNativeModuleRegistry"); + Systrace.beginSection(TRACE_TAG_REACT, "buildNativeModuleRegistry"); NativeModuleRegistry nativeModuleRegistry; try { nativeModuleRegistry = nativeModuleRegistryBuilder.build(); } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_END); } @@ -1567,7 +1561,7 @@ public class ReactInstanceManager { private void processPackage( ReactPackage reactPackage, NativeModuleRegistryBuilder nativeModuleRegistryBuilder) { - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage") + SystraceMessage.beginSection(TRACE_TAG_REACT, "processPackage") .arg("className", reactPackage.getClass().getSimpleName()) .flush(); if (reactPackage instanceof ReactPackageLogger) { @@ -1578,7 +1572,7 @@ public class ReactInstanceManager { if (reactPackage instanceof ReactPackageLogger) { ((ReactPackageLogger) reactPackage).endProcessPackage(); } - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } private static class InspectorTargetDelegateImpl diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 8c41b589ac2..6c625367010 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -11,7 +11,7 @@ import static com.facebook.infer.annotation.ThreadConfined.UI; import static com.facebook.react.uimanager.BlendModeHelper.needsIsolatedLayer; import static com.facebook.react.uimanager.common.UIManagerType.FABRIC; import static com.facebook.react.uimanager.common.UIManagerType.LEGACY; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import android.content.Context; import android.graphics.BlendMode; @@ -139,7 +139,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.onMeasure"); + Systrace.beginSection(TRACE_TAG_REACT, "ReactRootView.onMeasure"); ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_START); try { boolean measureSpecsUpdated = @@ -191,7 +191,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { } finally { ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_END); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } @@ -489,7 +489,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { ReactInstanceManager reactInstanceManager, String moduleName, @Nullable Bundle initialProperties) { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "startReactApplication"); + Systrace.beginSection(TRACE_TAG_REACT, "startReactApplication"); try { UiThreadUtil.assertOnUiThread(); @@ -516,7 +516,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { attachToReactInstanceManager(); } } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } @@ -682,7 +682,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { */ @Override public void runApplication() { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication"); + Systrace.beginSection(TRACE_TAG_REACT, "ReactRootView.runApplication"); try { if (!hasActiveReactInstance() || !isViewAttachedToReactInstance()) { return; @@ -711,7 +711,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams); } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } @@ -745,7 +745,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { } private void attachToReactInstanceManager() { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachToReactInstanceManager"); + Systrace.beginSection(TRACE_TAG_REACT, "attachToReactInstanceManager"); ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START); // React Native requires that the RootView id be managed entirely by React Native, and will @@ -778,7 +778,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { getViewTreeObserver().addOnGlobalLayoutListener(getCustomGlobalLayoutListener()); } finally { ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_END); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeSoLoader.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeSoLoader.kt index 390cc7de67d..0625883ff4f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeSoLoader.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeSoLoader.kt @@ -10,8 +10,6 @@ package com.facebook.react.bridge import com.facebook.react.common.annotations.internal.LegacyArchitecture import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger import com.facebook.soloader.SoLoader -import com.facebook.systrace.Systrace -import com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE @LegacyArchitecture internal object BridgeSoLoader { @@ -25,11 +23,9 @@ internal object BridgeSoLoader { if (initialized) { return } - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "BridgeSoLoader") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START) SoLoader.loadLibrary("reactnativejni") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_END) - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE) initialized = true } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 4e1caa6f7d3..2b904e38a2f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -9,7 +9,7 @@ package com.facebook.react.bridge; import static com.facebook.infer.annotation.Assertions.assertCondition; import static com.facebook.infer.annotation.ThreadConfined.UI; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import android.content.res.AssetManager; import androidx.annotation.Nullable; @@ -129,7 +129,7 @@ public class CatalystInstanceImpl implements CatalystInstance { JSExceptionHandler jSExceptionHandler, @Nullable ReactInstanceManagerInspectorTarget inspectorTarget) { FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge."); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstanceImpl"); + Systrace.beginSection(TRACE_TAG_REACT, "createCatalystInstanceImpl"); mHybridData = initHybrid(); @@ -144,10 +144,10 @@ public class CatalystInstanceImpl implements CatalystInstance { mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread(); mTraceListener = new JSProfilerTraceListener(this); mInspectorTarget = inspectorTarget; - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge"); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initializeCxxBridge"); + Systrace.beginSection(TRACE_TAG_REACT, "initializeCxxBridge"); initializeBridge( new InstanceCallback(this), @@ -158,7 +158,7 @@ public class CatalystInstanceImpl implements CatalystInstance { mNativeModuleRegistry.getCxxModules(), mInspectorTarget); FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge"); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); mJavaScriptContextHolder = new JavaScriptContextHolder(getJavaScriptContext()); } @@ -560,8 +560,7 @@ public class CatalystInstanceImpl implements CatalystInstance { private void incrementPendingJSCalls() { int oldPendingCalls = mPendingJSCalls.getAndIncrement(); boolean wasIdle = oldPendingCalls == 0; - Systrace.traceCounter( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, mJsPendingCallsTitleForTrace, oldPendingCalls + 1); + Systrace.traceCounter(TRACE_TAG_REACT, mJsPendingCallsTitleForTrace, oldPendingCalls + 1); if (wasIdle && !mBridgeIdleListeners.isEmpty()) { mNativeModulesQueueThread.runOnQueue( () -> { @@ -592,8 +591,7 @@ public class CatalystInstanceImpl implements CatalystInstance { // TODO(9604406): handle case of web workers injecting messages to main thread // Assertions.assertCondition(newPendingCalls >= 0); boolean isNowIdle = newPendingCalls == 0; - Systrace.traceCounter( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, mJsPendingCallsTitleForTrace, newPendingCalls); + Systrace.traceCounter(TRACE_TAG_REACT, mJsPendingCallsTitleForTrace, newPendingCalls); if (isNowIdle && !mBridgeIdleListeners.isEmpty()) { mNativeModulesQueueThread.runOnQueue( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java index a35ee9fd2ed..421a66f2088 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java @@ -8,7 +8,7 @@ package com.facebook.react.bridge; import static com.facebook.infer.annotation.Assertions.assertNotNull; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import androidx.annotation.Nullable; import com.facebook.debug.holder.PrinterHolder; @@ -234,7 +234,7 @@ class JavaMethodWrapper implements JavaModuleWrapper.NativeMethod { if (mArgumentsProcessed) { return; } - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processArguments") + SystraceMessage.beginSection(TRACE_TAG_REACT, "processArguments") .arg("method", mModuleWrapper.getName() + "." + mMethod.getName()) .flush(); try { @@ -247,7 +247,7 @@ class JavaMethodWrapper implements JavaModuleWrapper.NativeMethod { mArguments = new Object[mParameterTypes.length]; mJSArgumentsNeeded = calculateJSArgumentsNeeded(); } finally { - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } } @@ -334,7 +334,7 @@ class JavaMethodWrapper implements JavaModuleWrapper.NativeMethod { @Override public void invoke(JSInstance jsInstance, ReadableArray parameters) { String traceName = mModuleWrapper.getName() + "." + mMethod.getName(); - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "callJavaModuleMethod") + SystraceMessage.beginSection(TRACE_TAG_REACT, "callJavaModuleMethod") .arg("method", traceName) .flush(); if (DEBUG) { @@ -389,7 +389,7 @@ class JavaMethodWrapper implements JavaModuleWrapper.NativeMethod { throw new RuntimeException(createInvokeExceptionMessage(traceName), ite); } } finally { - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java index 80620bb3066..acdee40ab5b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java @@ -11,7 +11,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CONVERT_CONSTANTS_E import static com.facebook.react.bridge.ReactMarkerConstants.CONVERT_CONSTANTS_START; import static com.facebook.react.bridge.ReactMarkerConstants.GET_CONSTANTS_END; import static com.facebook.react.bridge.ReactMarkerConstants.GET_CONSTANTS_START; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import androidx.annotation.Nullable; import com.facebook.proguard.annotations.DoNotStrip; @@ -77,7 +77,7 @@ class JavaModuleWrapper { @DoNotStrip private void findMethods() { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "findMethods"); + Systrace.beginSection(TRACE_TAG_REACT, "findMethods"); Class classForMethods = mModuleHolder.getModule().getClass(); Class superClass = @@ -107,7 +107,7 @@ class JavaModuleWrapper { mDescs.add(md); } } - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); } @DoNotStrip @@ -121,27 +121,27 @@ class JavaModuleWrapper { @DoNotStrip public @Nullable NativeMap getConstants() { final String moduleName = getName(); - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "JavaModuleWrapper.getConstants") + SystraceMessage.beginSection(TRACE_TAG_REACT, "JavaModuleWrapper.getConstants") .arg("moduleName", moduleName) .flush(); ReactMarker.logMarker(GET_CONSTANTS_START, moduleName); BaseJavaModule baseJavaModule = getModule(); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "module.getConstants"); + Systrace.beginSection(TRACE_TAG_REACT, "module.getConstants"); Map map = baseJavaModule.getConstants(); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "create WritableNativeMap"); + Systrace.beginSection(TRACE_TAG_REACT, "create WritableNativeMap"); ReactMarker.logMarker(CONVERT_CONSTANTS_START, moduleName); try { return Arguments.makeNativeMap(map); } finally { ReactMarker.logMarker(CONVERT_CONSTANTS_END, moduleName); - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(TRACE_TAG_REACT); ReactMarker.logMarker(GET_CONSTANTS_END, moduleName); - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java index 608ff2c5610..2ee126b4d40 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java @@ -10,7 +10,7 @@ package com.facebook.react.bridge; import static com.facebook.infer.annotation.Assertions.assertNotNull; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_MODULE_END; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_MODULE_START; -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT; import androidx.annotation.GuardedBy; import androidx.annotation.Nullable; @@ -179,7 +179,7 @@ public class ModuleHolder { private NativeModule create() { SoftAssertions.assertCondition(mModule == null, "Creating an already created module."); ReactMarker.logMarker(CREATE_MODULE_START, mName, mInstanceKey); - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ModuleHolder.createModule") + SystraceMessage.beginSection(TRACE_TAG_REACT, "ModuleHolder.createModule") .arg("name", mName) .flush(); PrinterHolder.getPrinter() @@ -211,13 +211,13 @@ public class ModuleHolder { throw ex; } finally { ReactMarker.logMarker(CREATE_MODULE_END, mName, mInstanceKey); - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } return module; } private void doInitialize(NativeModule module) { - SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ModuleHolder.initialize") + SystraceMessage.beginSection(TRACE_TAG_REACT, "ModuleHolder.initialize") .arg("name", mName) .flush(); ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName, mInstanceKey); @@ -241,7 +241,7 @@ public class ModuleHolder { } } finally { ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END, mName, mInstanceKey); - SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(TRACE_TAG_REACT).flush(); } } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java index 717fecc955b..cdf08921c88 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java @@ -84,14 +84,13 @@ public class NativeModuleRegistry { /* package */ void notifyJSInstanceDestroy() { mReactApplicationContext.assertOnNativeModulesQueueThread(); - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "NativeModuleRegistry_notifyJSInstanceDestroy"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "NativeModuleRegistry_notifyJSInstanceDestroy"); try { for (ModuleHolder module : mModules.values()) { module.destroy(); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -101,13 +100,13 @@ public class NativeModuleRegistry { + "native modules are explicitly not initialized on the UI thread."); ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_START); Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "NativeModuleRegistry_notifyJSInstanceInitialized"); + Systrace.TRACE_TAG_REACT, "NativeModuleRegistry_notifyJSInstanceInitialized"); try { for (ModuleHolder module : mModules.values()) { module.markInitializable(); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); ReactMarker.logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_END); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricSoLoader.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricSoLoader.kt index 48bb654f661..8d352ca16d9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricSoLoader.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricSoLoader.kt @@ -20,11 +20,11 @@ internal object FabricSoLoader { if (didInit) { return } - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricSoLoader") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "FabricSoLoader") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START) SoLoader.loadLibrary("fabricjni") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_END) - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) didInit = true } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerProviderImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerProviderImpl.kt index 1398c4d487e..e2804569945 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerProviderImpl.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerProviderImpl.kt @@ -38,17 +38,13 @@ public class FabricUIManagerProviderImpl( * @throws IllegalStateException If runtimeExecutor or runtimeScheduler is null. */ override fun createUIManager(context: ReactApplicationContext): UIManager { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManagerProviderImpl.create") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "FabricUIManagerProviderImpl.create") val eventBeatManager = EventBeatManager() - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManagerProviderImpl.createUIManager") - + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "FabricUIManagerProviderImpl.createUIManager") val fabricUIManager = FabricUIManager(context, viewManagerRegistry, eventBeatManager) - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManagerProviderImpl.registerBinding") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "FabricUIManagerProviderImpl.registerBinding") val binding = FabricUIManagerBinding() val catalystInstance = context.catalystInstance @@ -65,9 +61,8 @@ public class FabricUIManagerProviderImpl( " runtimeScheduler must not be null") } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) - + Systrace.endSection(Systrace.TRACE_TAG_REACT) + Systrace.endSection(Systrace.TRACE_TAG_REACT) return fabricUIManager } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt index 875cb0e11ab..6e25eccca10 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt @@ -39,12 +39,11 @@ public class FabricEventEmitter(private val uiManager: FabricUIManager) : RCTMod params: WritableMap?, @EventCategoryDef category: Int ) { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricEventEmitter.receiveEvent('$eventName')") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "FabricEventEmitter.receiveEvent('$eventName')") try { uiManager.receiveEvent(surfaceId, targetTag, eventName, canCoalesceEvent, params, category) } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java index 51b0d8ea387..19d246a3291 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java @@ -181,8 +181,7 @@ public class MountItemDispatcher { // errors/glitches. if (viewCommandMountItemsToDispatch != null) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "MountItemDispatcher::mountViews viewCommandMountItems"); + Systrace.TRACE_TAG_REACT, "MountItemDispatcher::mountViews viewCommandMountItems"); for (DispatchCommandMountItem command : viewCommandMountItemsToDispatch) { if (ReactNativeFeatureFlags.enableFabricLogs()) { printMountItem(command, "dispatchMountItems: Executing viewCommandMountItem"); @@ -216,7 +215,7 @@ public class MountItemDispatcher { } } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } // If there are MountItems to dispatch, we make sure all the "pre mount items" are executed @@ -224,7 +223,7 @@ public class MountItemDispatcher { List preMountItemsToDispatch = getAndResetPreMountItems(); if (preMountItemsToDispatch != null) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "MountItemDispatcher::mountViews preMountItems"); + Systrace.TRACE_TAG_REACT, "MountItemDispatcher::mountViews preMountItems"); for (MountItem preMountItem : preMountItemsToDispatch) { if (ReactNativeFeatureFlags.enableFabricLogs()) { printMountItem(preMountItem, "dispatchMountItems: Executing preMountItem"); @@ -232,13 +231,12 @@ public class MountItemDispatcher { executeOrEnqueue(preMountItem); } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } if (mountItemsToDispatch != null) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "MountItemDispatcher::mountViews mountItems to execute"); + Systrace.TRACE_TAG_REACT, "MountItemDispatcher::mountViews mountItems to execute"); long batchedExecutionStartTime = SystemClock.uptimeMillis(); @@ -276,7 +274,7 @@ public class MountItemDispatcher { } mBatchedExecutionTime += SystemClock.uptimeMillis() - batchedExecutionStartTime; - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } mItemDispatchListener.didMountItems(mountItemsToDispatch); @@ -303,8 +301,7 @@ public class MountItemDispatcher { } private void dispatchPreMountItemsImpl(long deadline) { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "MountItemDispatcher::premountViews"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "MountItemDispatcher::premountViews"); // dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems from // reentering during dispatchPreMountItems @@ -331,7 +328,7 @@ public class MountItemDispatcher { mInDispatch = false; } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } private void executeOrEnqueue(MountItem item) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 12d726ab9f3..bd93824a905 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -656,7 +656,7 @@ public class SurfaceMountingManager { @Nullable EventEmitterWrapper eventEmitterWrapper, boolean isLayoutable) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "SurfaceMountingManager::createViewUnsafe(" + componentName + ")"); try { ReactStylesDiffMap propMap = new ReactStylesDiffMap(props); @@ -676,7 +676,7 @@ public class SurfaceMountingManager { viewState.mViewManager = viewManager; } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index 789be067d62..e2241e847ea 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -74,8 +74,7 @@ final class IntBufferBatchMountItem implements BatchMountItem { } private void beginMarkers(String reason) { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "IntBufferBatchMountItem::" + reason); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "IntBufferBatchMountItem::" + reason); if (mCommitNumber > 0) { ReactMarker.logFabricMarker( @@ -89,7 +88,7 @@ final class IntBufferBatchMountItem implements BatchMountItem { ReactMarkerConstants.FABRIC_BATCH_EXECUTION_END, null, mCommitNumber); } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } @Override @@ -120,7 +119,7 @@ final class IntBufferBatchMountItem implements BatchMountItem { String[] args = {"numInstructions", String.valueOf(numInstructions)}; Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "IntBufferBatchMountItem::mountInstructions::" + nameForInstructionString(type), args, args.length); @@ -181,7 +180,7 @@ final class IntBufferBatchMountItem implements BatchMountItem { "Invalid type argument to IntBufferBatchMountItem: " + type + " at index: " + i); } } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } endMarkers(); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/SystraceSection.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/SystraceSection.kt index 666ca92fa1c..8a1e427b57c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/SystraceSection.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/SystraceSection.kt @@ -14,10 +14,10 @@ import com.facebook.systrace.Systrace */ internal class SystraceSection(sectionName: String) : AutoCloseable { init { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, sectionName) + Systrace.beginSection(Systrace.TRACE_TAG_REACT, sectionName) } override fun close() { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/SystraceRequestListener.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/SystraceRequestListener.kt index 11f38425072..a740f2f1168 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/SystraceRequestListener.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/SystraceRequestListener.kt @@ -19,14 +19,14 @@ internal class SystraceRequestListener : BaseRequestListener() { private val requestsId: MutableMap> = mutableMapOf() override fun onProducerStart(requestId: String, producerName: String) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entryName = StringBuilder() entryName.append("FRESCO_PRODUCER_") entryName.append(producerName.replace(':', '_')) val requestPair = Pair.create(currentId, entryName.toString()) - Systrace.beginAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, requestPair.second, currentId) + Systrace.beginAsyncSection(Systrace.TRACE_TAG_REACT, requestPair.second, currentId) producerId[requestId] = requestPair currentId++ } @@ -36,13 +36,13 @@ internal class SystraceRequestListener : BaseRequestListener() { producerName: String, extraMap: Map? ) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = producerId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) producerId.remove(requestId) } } @@ -53,13 +53,13 @@ internal class SystraceRequestListener : BaseRequestListener() { t: Throwable, extraMap: Map? ) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = producerId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) producerId.remove(requestId) } } @@ -69,19 +69,19 @@ internal class SystraceRequestListener : BaseRequestListener() { producerName: String, extraMap: Map? ) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = producerId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) producerId.remove(requestId) } } override fun onProducerEvent(requestId: String, producerName: String, eventName: String) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entryName = StringBuilder() @@ -92,7 +92,7 @@ internal class SystraceRequestListener : BaseRequestListener() { entryName.append("_") entryName.append(eventName.replace(':', '_')) Systrace.traceInstant( - Systrace.TRACE_TAG_REACT_FRESCO, entryName.toString(), Systrace.EventScope.THREAD) + Systrace.TRACE_TAG_REACT, entryName.toString(), Systrace.EventScope.THREAD) } override fun onRequestStart( @@ -101,7 +101,7 @@ internal class SystraceRequestListener : BaseRequestListener() { requestId: String, isPrefetch: Boolean ) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } @@ -109,19 +109,19 @@ internal class SystraceRequestListener : BaseRequestListener() { entryName.append("FRESCO_REQUEST_") entryName.append(request.sourceUri.toString().replace(':', '_')) val requestPair = Pair.create(currentId, entryName.toString()) - Systrace.beginAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, requestPair.second, currentId) + Systrace.beginAsyncSection(Systrace.TRACE_TAG_REACT, requestPair.second, currentId) requestsId[requestId] = requestPair currentId++ } override fun onRequestSuccess(request: ImageRequest, requestId: String, isPrefetch: Boolean) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = requestsId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) requestsId.remove(requestId) } } @@ -132,25 +132,25 @@ internal class SystraceRequestListener : BaseRequestListener() { throwable: Throwable, isPrefetch: Boolean ) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = requestsId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) requestsId.remove(requestId) } } override fun onRequestCancellation(requestId: String) { - if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) { + if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT)) { return } val entry = requestsId[requestId] if (entry != null) { - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_FRESCO, entry.second, entry.first) + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, entry.second, entry.first) requestsId.remove(requestId) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java index 783da763cee..741aa4d6d8e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java @@ -116,7 +116,7 @@ final class ReactInstance { @Nullable ReactHostInspectorTarget reactHostInspectorTarget) { mBridgelessReactContext = bridgelessReactContext; - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.initialize"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.initialize"); /** * Prepare the ReactInstance by installing JSI bindings, initializing Fabric + TurboModules, and @@ -148,9 +148,7 @@ final class ReactInstance { BindingsInstaller bindingsInstaller = delegate.getBindingsInstaller(); // Notify JS if profiling is enabled boolean isProfiling = - BuildConfig.ENABLE_PERFETTO - || Systrace.isTracing( - Systrace.TRACE_TAG_REACT_APPS | Systrace.TRACE_TAG_REACT_JS_VM_CALLS); + BuildConfig.ENABLE_PERFETTO || Systrace.isTracing(Systrace.TRACE_TAG_REACT); mHybridData = initHybrid( @@ -167,8 +165,7 @@ final class ReactInstance { mJavaScriptContextHolder = new JavaScriptContextHolder(getJavaScriptContext()); // Set up TurboModules - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.initialize#initTurboModules"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.initialize#initTurboModules"); List reactPackages = new ArrayList<>(); reactPackages.add( @@ -196,11 +193,10 @@ final class ReactInstance { getJSCallInvokerHolder(), getNativeMethodCallInvokerHolder()); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); // Set up Fabric - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.initialize#initFabric"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.initialize#initFabric"); mViewManagerResolver = new BridgelessViewManagerResolver(reactPackages, mBridgelessReactContext); @@ -284,8 +280,8 @@ final class ReactInstance { // Initialize the FabricUIManager mFabricUIManager.initialize(); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } private static Map createConstants( @@ -293,14 +289,14 @@ final class ReactInstance { @Nullable Map customBubblingEvents, @Nullable Map customDirectEvents) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "CreateUIManagerConstants") .arg("Lazy", false) .flush(); try { return UIManagerModuleConstantsHelper.createConstants( viewManagers, customBubblingEvents, customDirectEvents); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } @@ -308,7 +304,7 @@ final class ReactInstance { private static NativeMap getConstantsForViewManager( ViewManager viewManager, Map customDirectEvents) { SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.getConstantsForViewManager") + Systrace.TRACE_TAG_REACT, "ReactInstance.getConstantsForViewManager") .arg("ViewManager", viewManager.getName()) .arg("Lazy", true) .flush(); @@ -318,7 +314,7 @@ final class ReactInstance { viewManager, null, null, null, customDirectEvents); return Arguments.makeNativeMap(viewManagerConstants); } finally { - SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(Systrace.TRACE_TAG_REACT).flush(); } } @@ -327,13 +323,12 @@ final class ReactInstance { .getNativeModulesQueueThread() .runOnQueue( () -> { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "initializeEagerTurboModules"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "initializeEagerTurboModules"); // Eagerly initialize TurboModules for (String moduleName : mTurboModuleManager.getEagerInitModuleNames()) { mTurboModuleManager.getModule(moduleName); } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); }); } @@ -375,7 +370,7 @@ final class ReactInstance { } public void loadJSBundle(JSBundleLoader bundleLoader) { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.loadJSBundle"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.loadJSBundle"); bundleLoader.loadScript( new JSBundleLoaderDelegate() { @Override @@ -402,7 +397,7 @@ final class ReactInstance { mBridgelessReactContext.setSourceURL(deviceURL); } }); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } public boolean hasNativeModule(Class nativeModuleInterface) { @@ -433,10 +428,10 @@ final class ReactInstance { @ThreadConfined("ReactHost") /* package */ void prerenderSurface(ReactSurfaceImpl surface) { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.prerenderSurface"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.prerenderSurface"); FLog.d(TAG, "call prerenderSurface with surface: " + surface.getModuleName()); mFabricUIManager.startSurface(surface.getSurfaceHandler(), surface.getContext(), null); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } /** @@ -447,7 +442,7 @@ final class ReactInstance { @ThreadConfined("ReactHost") /* package */ void startSurface(ReactSurfaceImpl surface) { FLog.d(TAG, "startSurface() is called with surface: " + surface.getSurfaceID()); - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstance.startSurface"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactInstance.startSurface"); View view = surface.getView(); if (view == null) { @@ -472,7 +467,7 @@ final class ReactInstance { } else { mFabricUIManager.startSurface(surface.getSurfaceHandler(), surface.getContext(), view); } - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } @ThreadConfined("ReactHost") diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt index d926007ff25..185e349ada8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt @@ -41,7 +41,7 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactSurfaceView.onMeasure") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactSurfaceView.onMeasure") var width = 0 var height = 0 val widthMode = MeasureSpec.getMode(widthMeasureSpec) @@ -71,7 +71,7 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa val viewportOffset = viewportOffset surface.updateLayoutSpecs( widthMeasureSpec, heightMeasureSpec, viewportOffset.x, viewportOffset.y) - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index 4a9e797c747..ea338dcc71d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -179,7 +179,7 @@ public class NativeViewHierarchyManager { } UiThreadUtil.assertOnUiThread(); SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_VIEW, "NativeViewHierarchyManager_updateLayout") + Systrace.TRACE_TAG_REACT, "NativeViewHierarchyManager_updateLayout") .arg("parentTag", parentTag) .arg("tag", tag) .flush(); @@ -242,7 +242,7 @@ public class NativeViewHierarchyManager { updateLayout(viewToUpdate, x, y, width, height); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_VIEW); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -286,8 +286,7 @@ public class NativeViewHierarchyManager { (initialProps != null ? initialProps.toString() : "")); } UiThreadUtil.assertOnUiThread(); - SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_VIEW, "NativeViewHierarchyManager_createView") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "NativeViewHierarchyManager_createView") .arg("tag", tag) .arg("className", className) .flush(); @@ -299,7 +298,7 @@ public class NativeViewHierarchyManager { mTagsToViews.put(tag, view); mTagsToViewManagers.put(tag, viewManager); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_VIEW); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 08a7f7a4e56..065e699e933 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -612,8 +612,7 @@ public class UIImplementation { /** Invoked at the end of the transaction to commit any updates to the node hierarchy. */ public void dispatchViewUpdates(int batchId) { - SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementation.dispatchViewUpdates") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "UIImplementation.dispatchViewUpdates") .arg("batchId", batchId) .flush(); final long commitStartTime = SystemClock.uptimeMillis(); @@ -622,7 +621,7 @@ public class UIImplementation { mNativeViewHierarchyOptimizer.onBatchComplete(); mOperationsQueue.dispatchViewUpdates(batchId, commitStartTime, mLastCalculateLayoutTime); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -638,8 +637,7 @@ public class UIImplementation { } protected void updateViewHierarchy() { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementation.updateViewHierarchy"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "UIImplementation.updateViewHierarchy"); try { for (int i = 0; i < mShadowNodeRegistry.getRootNodeCount(); i++) { int tag = mShadowNodeRegistry.getRootTag(i); @@ -647,19 +645,18 @@ public class UIImplementation { if (cssRoot.getWidthMeasureSpec() != null && cssRoot.getHeightMeasureSpec() != null) { SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "UIImplementation.notifyOnBeforeLayoutRecursive") + Systrace.TRACE_TAG_REACT, "UIImplementation.notifyOnBeforeLayoutRecursive") .arg("rootTag", cssRoot.getReactTag()) .flush(); try { notifyOnBeforeLayoutRecursive(cssRoot); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } calculateRootLayout(cssRoot); SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementation.applyUpdatesRecursive") + Systrace.TRACE_TAG_REACT, "UIImplementation.applyUpdatesRecursive") .arg("rootTag", cssRoot.getReactTag()) .flush(); try { @@ -678,7 +675,7 @@ public class UIImplementation { } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } if (mLayoutUpdateListener != null) { @@ -687,7 +684,7 @@ public class UIImplementation { } } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -921,7 +918,7 @@ public class UIImplementation { } protected void calculateRootLayout(ReactShadowNode cssRoot) { - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "cssRoot.calculateLayout") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "cssRoot.calculateLayout") .arg("rootTag", cssRoot.getReactTag()) .flush(); long startTime = SystemClock.uptimeMillis(); @@ -936,7 +933,7 @@ public class UIImplementation { ? YogaConstants.UNDEFINED : MeasureSpec.getSize(heightSpec)); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); mLastCalculateLayoutTime = SystemClock.uptimeMillis() - startTime; } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 22ffaf4d2b5..55ec5168205 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -235,13 +235,13 @@ public class UIManagerModule extends ReactContextBaseJavaModule private static Map createConstants(ViewManagerResolver viewManagerResolver) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "CreateUIManagerConstants") .arg("Lazy", true) .flush(); try { return UIManagerModuleConstantsHelper.createConstants(viewManagerResolver); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } @@ -251,14 +251,14 @@ public class UIManagerModule extends ReactContextBaseJavaModule @Nullable Map customBubblingEvents, @Nullable Map customDirectEvents) { ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_START); - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "CreateUIManagerConstants") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "CreateUIManagerConstants") .arg("Lazy", false) .flush(); try { return UIManagerModuleConstantsHelper.createConstants( viewManagers, customBubblingEvents, customDirectEvents); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_CONSTANTS_END); } } @@ -276,7 +276,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule public static @Nullable WritableMap getConstantsForViewManager( ViewManager viewManager, Map customDirectEvents) { SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.getConstantsForViewManager") + Systrace.TRACE_TAG_REACT, "UIManagerModule.getConstantsForViewManager") .arg("ViewManager", viewManager.getName()) .arg("Lazy", true) .flush(); @@ -289,7 +289,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule } return null; } finally { - SystraceMessage.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE).flush(); + SystraceMessage.endSection(Systrace.TRACE_TAG_REACT).flush(); } } @@ -363,7 +363,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule */ @Override public int addRootView(final T rootView, WritableMap initialProps) { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.addRootView"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "UIManagerModule.addRootView"); final int tag = ReactRootViewTagGenerator.getNextRootViewTag(); final ReactApplicationContext reactApplicationContext = getReactApplicationContext(); @@ -376,7 +376,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule -1); mUIImplementation.registerRootView(rootView, tag, themedRootContext); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); return tag; } @@ -673,7 +673,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule int batchId = mBatchId; mBatchId++; - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "onBatchCompleteUI") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "onBatchCompleteUI") .arg("BatchId", batchId) .flush(); for (UIManagerModuleListener listener : mListeners) { @@ -690,7 +690,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule mUIImplementation.dispatchViewUpdates(batchId); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index a2b4f86caf4..53d73f01287 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -144,12 +144,12 @@ public class UIViewOperationQueue { mWidth = width; mHeight = height; mLayoutDirection = layoutDirection; - Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "updateLayout", mTag); + Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT, "updateLayout", mTag); } @Override public void execute() { - Systrace.endAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "updateLayout", mTag); + Systrace.endAsyncFlow(Systrace.TRACE_TAG_REACT, "updateLayout", mTag); mNativeViewHierarchyManager.updateLayout( mParentTag, mTag, mX, mY, mWidth, mHeight, mLayoutDirection); } @@ -170,12 +170,12 @@ public class UIViewOperationQueue { mThemedContext = themedContext; mClassName = className; mInitialProps = initialProps; - Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "createView", mTag); + Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT, "createView", mTag); } @Override public void execute() { - Systrace.endAsyncFlow(Systrace.TRACE_TAG_REACT_VIEW, "createView", mTag); + Systrace.endAsyncFlow(Systrace.TRACE_TAG_REACT, "createView", mTag); mNativeViewHierarchyManager.createView(mThemedContext, mTag, mClassName, mInitialProps); } } @@ -796,7 +796,7 @@ public class UIViewOperationQueue { public void dispatchViewUpdates( final int batchId, final long commitStartTime, final long layoutTime) { SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIViewOperationQueue.dispatchViewUpdates") + Systrace.TRACE_TAG_REACT, "UIViewOperationQueue.dispatchViewUpdates") .arg("batchId", batchId) .flush(); try { @@ -839,7 +839,7 @@ public class UIViewOperationQueue { new Runnable() { @Override public void run() { - SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "DispatchUI") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "DispatchUI") .arg("BatchId", batchId) .flush(); try { @@ -900,22 +900,22 @@ public class UIViewOperationQueue { mThreadCpuTime = nativeModulesThreadCpuTime; Systrace.beginAsyncSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "delayBeforeDispatchViewUpdates", 0, mProfiledBatchCommitStartTime * 1000000); Systrace.endAsyncSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "delayBeforeDispatchViewUpdates", 0, mProfiledBatchDispatchViewUpdatesTime * 1000000); Systrace.beginAsyncSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "delayBeforeBatchRunStart", 0, mProfiledBatchDispatchViewUpdatesTime * 1000000); Systrace.endAsyncSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "delayBeforeBatchRunStart", 0, mProfiledBatchRunStartTime * 1000000); @@ -931,17 +931,16 @@ public class UIViewOperationQueue { mIsInIllegalUIState = true; throw e; } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } }; - SystraceMessage.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "acquiring mDispatchRunnablesLock") + SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "acquiring mDispatchRunnablesLock") .arg("batchId", batchId) .flush(); synchronized (mDispatchRunnablesLock) { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); mDispatchUIRunnables.add(runOperations); } @@ -960,7 +959,7 @@ public class UIViewOperationQueue { }); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -1006,11 +1005,8 @@ public class UIViewOperationQueue { mIsProfilingNextBatch = false; Systrace.beginAsyncSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "batchedExecutionTime", - 0, - batchedExecutionStartTime * 1000000); - Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "batchedExecutionTime", 0); + Systrace.TRACE_TAG_REACT, "batchedExecutionTime", 0, batchedExecutionStartTime * 1000000); + Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT, "batchedExecutionTime", 0); } mNonBatchedExecutionTotalTime = 0; } @@ -1050,11 +1046,11 @@ public class UIViewOperationQueue { return; } - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "dispatchNonBatchedUIOperations"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "dispatchNonBatchedUIOperations"); try { dispatchPendingNonBatchedOperations(frameTimeNanos); } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } flushPendingBatches(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java index 13cfe4ec64a..6d378a0ee39 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java @@ -119,8 +119,7 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe synchronized (mEventsStagingLock) { mEventStaging.add(event); - Systrace.startAsyncFlow( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, event.getEventName(), event.getUniqueID()); + Systrace.startAsyncFlow(Systrace.TRACE_TAG_REACT, event.getEventName(), event.getUniqueID()); } maybePostFrameCallbackFromNonUI(); } @@ -261,20 +260,20 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe post(); } - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ScheduleDispatchFrameCallback"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ScheduleDispatchFrameCallback"); try { moveStagedEventsToDispatchQueue(); if (!mHasDispatchScheduled) { mHasDispatchScheduled = true; Systrace.startAsyncFlow( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "ScheduleDispatchFrameCallback", mHasDispatchScheduledCount.get()); mReactContext.runOnJSQueueThread(mDispatchEventsRunnable); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -318,10 +317,10 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe @Override public void run() { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "DispatchEventsRunnable"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "DispatchEventsRunnable"); try { Systrace.endAsyncFlow( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "ScheduleDispatchFrameCallback", mHasDispatchScheduledCount.getAndIncrement()); mHasDispatchScheduled = false; @@ -339,7 +338,7 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe continue; } Systrace.endAsyncFlow( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, event.getEventName(), event.getUniqueID()); + Systrace.TRACE_TAG_REACT, event.getEventName(), event.getUniqueID()); event.dispatchModern(mReactEventEmitter); event.dispose(); @@ -352,7 +351,7 @@ public class EventDispatcherImpl implements EventDispatcher, LifecycleEventListe listener.onBatchEventDispatched(); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.kt index 54dbd18041e..d30e01b2dac 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.kt @@ -44,13 +44,13 @@ internal class FabricEventDispatcher( private var isDispatchScheduled = false private val dispatchEventsRunnable = Runnable { isDispatchScheduled = false - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "BatchEventDispatchedListeners") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "BatchEventDispatchedListeners") try { for (listener in postEventDispatchListeners) { listener.onBatchEventDispatched() } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } @@ -75,7 +75,7 @@ internal class FabricEventDispatcher( private fun dispatchSynchronous(event: Event<*>) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + Systrace.TRACE_TAG_REACT, "FabricEventDispatcher.dispatchSynchronous('" + event.eventName + "')") try { val fabricUIManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC) @@ -96,7 +96,7 @@ internal class FabricEventDispatcher( "Fabric UIManager expected to implement SynchronousEventReceiver.")) } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } @@ -182,13 +182,13 @@ internal class FabricEventDispatcher( dispatchBatchedEvents() } - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "BatchEventDispatchedListeners") + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "BatchEventDispatchedListeners") try { for (listener in postEventDispatchListeners) { listener.onBatchEventDispatched() } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt index 77f694d08ff..97813be1e0a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt @@ -120,8 +120,7 @@ internal object TouchesHelper { @JvmStatic public fun sendTouchEvent(eventEmitter: RCTModernEventEmitter, event: TouchEvent) { Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "TouchesHelper.sentTouchEventModern(" + event.eventName + ")") + Systrace.TRACE_TAG_REACT, "TouchesHelper.sentTouchEventModern(" + event.eventName + ")") try { val type = event.getTouchEventType() val motionEvent = event.getMotionEvent() @@ -180,7 +179,7 @@ internal object TouchesHelper { event.eventCategory) } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) + Systrace.endSection(Systrace.TRACE_TAG_REACT) } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index e037f05ad19..a3aa393ecf1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -485,8 +485,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView FLog.i(TAG, "onScrollChanged[%d] x %d y %d oldx %d oldy %d", getId(), x, y, oldX, oldY); } - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactHorizontalScrollView.onScrollChanged"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactHorizontalScrollView.onScrollChanged"); try { super.onScrollChanged(x, y, oldX, oldY); @@ -502,7 +501,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView mOnScrollDispatchHelper.getYFlingVelocity()); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -778,8 +777,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView return; } - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactHorizontalScrollView.updateClippingRect"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactHorizontalScrollView.updateClippingRect"); try { Assertions.assertNotNull(mClippingRect); @@ -789,7 +787,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView ((ReactClippingViewGroup) contentView).updateClippingRect(); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index 71acfa6288b..d463a90a8aa 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -404,7 +404,7 @@ public class ReactScrollView extends ScrollView @Override protected void onScrollChanged(int x, int y, int oldX, int oldY) { - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactScrollView.onScrollChanged"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactScrollView.onScrollChanged"); try { super.onScrollChanged(x, y, oldX, oldY); @@ -420,7 +420,7 @@ public class ReactScrollView extends ScrollView mOnScrollDispatchHelper.getYFlingVelocity()); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } @@ -532,8 +532,7 @@ public class ReactScrollView extends ScrollView return; } - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactScrollView.updateClippingRect"); + Systrace.beginSection(Systrace.TRACE_TAG_REACT, "ReactScrollView.updateClippingRect"); try { Assertions.assertNotNull(mClippingRect); @@ -543,7 +542,7 @@ public class ReactScrollView extends ScrollView ((ReactClippingViewGroup) contentView).updateClippingRect(); } } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + Systrace.endSection(Systrace.TRACE_TAG_REACT); } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.kt index 536edc5efdb..eab14c19ed3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.kt @@ -18,11 +18,7 @@ import kotlin.text.StringBuilder @Suppress("UNUSED_PARAMETER") internal object Systrace { - const val TRACE_TAG_REACT_JAVA_BRIDGE: Long = 0L - const val TRACE_TAG_REACT_APPS: Long = 0L - const val TRACE_TAG_REACT_FRESCO: Long = 0L - const val TRACE_TAG_REACT_VIEW: Long = 0L - const val TRACE_TAG_REACT_JS_VM_CALLS: Long = 0L + public const val TRACE_TAG_REACT: Long = 0L @JvmStatic fun registerListener(listener: TraceListener?): Unit = Unit diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp index 4be8efe6e81..65a76fc7618 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp @@ -118,7 +118,7 @@ void JavaNativeModule::invoke( "invoke"); #ifdef WITH_FBSYSTRACE if (callId != -1) { - fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId); + fbsystrace_end_async_flow(TRACE_TAG_REACT, "native", callId); } #endif invokeMethod( diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp index 6f178ad69ee..6eeec15ad65 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -214,7 +215,6 @@ MethodCallResult MethodInvoker::invoke( isSync_ ? "callJavaSyncHook" : "callJavaModuleMethod", "method", traceName_); - if (params.size() != jsArgCount_) { throw std::invalid_argument( "expected " + std::to_string(jsArgCount_) + " arguments, got " + diff --git a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp index f43873ae78a..af2101b70c3 100644 --- a/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp +++ b/packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp @@ -187,7 +187,7 @@ void CxxNativeModule::invoke( callId]() { #ifdef WITH_FBSYSTRACE if (callId != -1) { - fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId); + fbsystrace_end_async_flow(TRACE_TAG_REACT, "native", callId); } #else (void)(callId); diff --git a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp index a7c9af23f9b..785f212fc12 100644 --- a/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp +++ b/packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp @@ -173,8 +173,7 @@ void NativeToJsBridge::callFunction( int systraceCookie = -1; #ifdef WITH_FBSYSTRACE systraceCookie = m_systraceCookie++; - FbSystraceAsyncFlow::begin( - TRACE_TAG_REACT_CXX_BRIDGE, "JSCall", systraceCookie); + FbSystraceAsyncFlow::begin(TRACE_TAG_REACT, "JSCall", systraceCookie); #endif runOnExecutorQueue([this, @@ -192,8 +191,7 @@ void NativeToJsBridge::callFunction( } #ifdef WITH_FBSYSTRACE - FbSystraceAsyncFlow::end( - TRACE_TAG_REACT_CXX_BRIDGE, "JSCall", systraceCookie); + FbSystraceAsyncFlow::end(TRACE_TAG_REACT, "JSCall", systraceCookie); TraceSection s( "NativeToJsBridge::callFunction", "module", module, "method", method); #else @@ -212,8 +210,7 @@ void NativeToJsBridge::invokeCallback( int systraceCookie = -1; #ifdef WITH_FBSYSTRACE systraceCookie = m_systraceCookie++; - FbSystraceAsyncFlow::begin( - TRACE_TAG_REACT_CXX_BRIDGE, "", systraceCookie); + FbSystraceAsyncFlow::begin(TRACE_TAG_REACT, "", systraceCookie); #endif runOnExecutorQueue( @@ -227,8 +224,7 @@ void NativeToJsBridge::invokeCallback( "Attempting to invoke JS callback on a bad application bundle."); } #ifdef WITH_FBSYSTRACE - FbSystraceAsyncFlow::end( - TRACE_TAG_REACT_CXX_BRIDGE, "", systraceCookie); + FbSystraceAsyncFlow::end(TRACE_TAG_REACT, "", systraceCookie); TraceSection s("NativeToJsBridge::invokeCallback"); #else (void)(systraceCookie); diff --git a/packages/react-native/ReactCommon/cxxreact/TraceSection.h b/packages/react-native/ReactCommon/cxxreact/TraceSection.h index 2678aa1c4c9..9e9bc2d510e 100644 --- a/packages/react-native/ReactCommon/cxxreact/TraceSection.h +++ b/packages/react-native/ReactCommon/cxxreact/TraceSection.h @@ -71,7 +71,7 @@ struct ConcreteTraceSection { explicit ConcreteTraceSection( const char* name, ConvertsToStringPiece&&... args) - : m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) {} + : m_section(TRACE_TAG_REACT, name, args...) {} private: fbsystrace::FbSystraceSection m_section; diff --git a/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoLogger.cpp b/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoLogger.cpp index 78a44981044..c895334b7c5 100644 --- a/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoLogger.cpp +++ b/packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoLogger.cpp @@ -43,7 +43,7 @@ int64_t getDeltaNanos(double jsTime) { #if defined(WITH_PERFETTO) return TRACE_EVENT_CATEGORY_ENABLED("react-native"); #elif defined(WITH_FBSYSTRACE) - return fbsystrace_is_tracing(TRACE_TAG_REACT_APPS); + return fbsystrace_is_tracing(TRACE_TAG_REACT); #else return false; #endif @@ -68,9 +68,9 @@ int64_t getDeltaNanos(double jsTime) { #elif defined(WITH_FBSYSTRACE) static int cookie = 0; fbsystrace_begin_async_section_with_timedelta( - TRACE_TAG_REACT_APPS, eventName.data(), cookie, getDeltaNanos(startTime)); + TRACE_TAG_REACT, eventName.data(), cookie, getDeltaNanos(startTime)); fbsystrace_end_async_section_with_timedelta( - TRACE_TAG_REACT_APPS, eventName.data(), cookie, getDeltaNanos(endTime)); + TRACE_TAG_REACT, eventName.data(), cookie, getDeltaNanos(endTime)); cookie++; #endif } @@ -90,10 +90,7 @@ int64_t getDeltaNanos(double jsTime) { #elif defined(WITH_FBSYSTRACE) static const char* kTrackName = "# Web Performance: Markers"; fbsystrace_instant_for_track_with_timedelta( - TRACE_TAG_REACT_APPS, - kTrackName, - eventName.data(), - getDeltaNanos(startTime)); + TRACE_TAG_REACT, kTrackName, eventName.data(), getDeltaNanos(startTime)); #endif }