diff --git a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js b/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js index 452872e1014d4f..1326c2346cb441 100644 --- a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js +++ b/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js @@ -36,12 +36,6 @@ export type FeatureFlags = {| * traffic. */ animatedShouldUseSingleOp: () => boolean, - /** - * Enables GlobalPerformanceLogger replacement with a WebPerformance API based - * implementation. Tri-state due to being sensitive to initialization order - * vs the platform-specific ReactNativeFeatureFlags implementation. - */ - isGlobalWebPerformanceLoggerEnabled: () => ?boolean, /** * Enables access to the host tree in Fabric using DOM-compatible APIs. */ @@ -62,7 +56,6 @@ const ReactNativeFeatureFlags: FeatureFlags = { shouldPressibilityUseW3CPointerEventsForHover: () => false, animatedShouldDebounceQueueFlush: () => false, animatedShouldUseSingleOp: () => false, - isGlobalWebPerformanceLoggerEnabled: () => undefined, enableAccessToHostTreeInFabric: () => false, shouldUseAnimatedObjectForTransform: () => false, shouldUseSetNativePropsInFabric: () => false, diff --git a/packages/react-native/Libraries/Utilities/GlobalPerformanceLogger.js b/packages/react-native/Libraries/Utilities/GlobalPerformanceLogger.js index ed72a504488bc2..d119f6316c1227 100644 --- a/packages/react-native/Libraries/Utilities/GlobalPerformanceLogger.js +++ b/packages/react-native/Libraries/Utilities/GlobalPerformanceLogger.js @@ -19,7 +19,6 @@ import createPerformanceLogger from './createPerformanceLogger'; * that are logged during loading bundle. If you want to log something from your * React component you should use PerformanceLoggerContext instead. */ -const GlobalPerformanceLogger: IPerformanceLogger = - createPerformanceLogger(true); +const GlobalPerformanceLogger: IPerformanceLogger = createPerformanceLogger(); module.exports = GlobalPerformanceLogger; diff --git a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js index 91c1f749f25110..092877c3570630 100644 --- a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js +++ b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js @@ -16,8 +16,6 @@ import type { } from './IPerformanceLogger'; import * as Systrace from '../Performance/Systrace'; -import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags'; -import NativePerformance from '../WebPerformance/NativePerformance'; import infoLog from './infoLog'; const _cookies: {[key: string]: number, ...} = {}; @@ -26,7 +24,7 @@ const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally // This is the prefix for optional logging points/timespans as marks/measures via Performance API, // used to separate these internally from other marks/measures -const WEB_PERFORMANCE_PREFIX = 'global_perf_'; +const WEB_PERFORMANCE_PREFIX = 'web_perf_'; export const getCurrentTimestamp: () => number = global.nativeQPLTimestamp ?? (() => global.performance.now()); @@ -37,22 +35,12 @@ class PerformanceLogger implements IPerformanceLogger { _points: {[key: string]: ?number} = {}; _pointExtras: {[key: string]: ?Extras, ...} = {}; _closed: boolean = false; - _isGlobalLogger: boolean = false; - _isGlobalWebPerformanceLoggerEnabled: ?boolean; + _isLoggingForWebPerformance: boolean = false; - constructor(isGlobalLogger?: boolean) { - this._isGlobalLogger = isGlobalLogger === true; - } - - _isLoggingForWebPerformance(): boolean { - if (!this._isGlobalLogger || NativePerformance == null) { - return false; - } - if (this._isGlobalWebPerformanceLoggerEnabled == null) { - this._isGlobalWebPerformanceLoggerEnabled = - ReactNativeFeatureFlags.isGlobalWebPerformanceLoggerEnabled(); - } - return this._isGlobalWebPerformanceLoggerEnabled === true; + // When `isLoggingForWebPerformance` is true, the data will be additionally logged via + // Performance.mark/measure API, if available. + constructor(isLoggingForWebPerformance?: boolean) { + this._isLoggingForWebPerformance = isLoggingForWebPerformance === true; } // NOTE: The Performance.mark/measure calls are wrapped here to ensure that @@ -63,7 +51,7 @@ class PerformanceLogger implements IPerformanceLogger { // In most of the other cases this kind of check for `performance` being defined // wouldn't be necessary. _performanceMark(key: string, startTime: number) { - if (this._isLoggingForWebPerformance()) { + if (this._isLoggingForWebPerformance) { global.performance?.mark?.(key, { startTime, }); @@ -75,7 +63,7 @@ class PerformanceLogger implements IPerformanceLogger { start: number | string, end: number | string, ) { - if (this._isLoggingForWebPerformance()) { + if (this._isLoggingForWebPerformance) { global.performance?.measure?.(key, { start, end, @@ -365,7 +353,7 @@ export type {Extras, ExtraValue, IPerformanceLogger, Timespan}; * The loggers need to have minimal overhead since they're used in production. */ export default function createPerformanceLogger( - isGlobalLogger?: boolean, + isLoggingForWebPerformance?: boolean, ): IPerformanceLogger { - return new PerformanceLogger(isGlobalLogger); + return new PerformanceLogger(isLoggingForWebPerformance); }