From 789912441e67f18dcbfa105fafc8a3662afb843e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 5 Oct 2022 15:17:53 -0700 Subject: [PATCH] Remove unnecessary checks for profiling in dev mode Summary: It doesn't make sense to have checks for whether we're profiling or not in `__DEV__` blocks, where we shouldn't be profiling in the first case. We're going to remove the `global.__RCTProfileIsProfiling` flag in favor of a function that checks if we're profiling in real time (as opposed to checking if we're profiling only on startup, which is what that value does). This is just to make that migration easier without having to migrate callsites that are bad practices anyway. Changelog: [internal] Reviewed By: rshest Differential Revision: D40095841 fbshipit-source-id: ba6cdf4bef8a4c169c50a974671c21144ccee92b --- Libraries/Core/setUpBatchedBridge.js | 2 +- Libraries/Core/setUpDeveloperTools.js | 10 ++++------ Libraries/ReactNative/AppContainer.js | 15 +++++---------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Libraries/Core/setUpBatchedBridge.js b/Libraries/Core/setUpBatchedBridge.js index 4ceff36bc50..abac069677b 100644 --- a/Libraries/Core/setUpBatchedBridge.js +++ b/Libraries/Core/setUpBatchedBridge.js @@ -52,7 +52,7 @@ registerModule('GlobalPerformanceLogger', () => require('../Utilities/GlobalPerformanceLogger'), ); -if (__DEV__ && !global.__RCTProfileIsProfiling) { +if (__DEV__) { registerModule('HMRClient', () => require('../Utilities/HMRClient')); } else { registerModule('HMRClient', () => require('../Utilities/HMRClientProdShim')); diff --git a/Libraries/Core/setUpDeveloperTools.js b/Libraries/Core/setUpDeveloperTools.js index 9d1a342ada6..06f2079b878 100644 --- a/Libraries/Core/setUpDeveloperTools.js +++ b/Libraries/Core/setUpDeveloperTools.js @@ -17,13 +17,11 @@ declare var console: typeof console & {_isPolyfilled: boolean, ...}; * You can use this module directly, or just require InitializeCore. */ if (__DEV__) { - if (!global.__RCTProfileIsProfiling) { - require('./setUpReactDevTools'); + require('./setUpReactDevTools'); - // Set up inspector - const JSInspector = require('../JSInspector/JSInspector'); - JSInspector.registerAgent(require('../JSInspector/NetworkAgent')); - } + // Set up inspector + const JSInspector = require('../JSInspector/JSInspector'); + JSInspector.registerAgent(require('../JSInspector/NetworkAgent')); // Note we can't check if console is "native" because it would appear "native" in JSC and Hermes. // We also can't check any properties that don't exist in the Chrome worker environment. diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index b2e654f729e..cf3f1d0274e 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -50,10 +50,7 @@ class AppContainer extends React.Component { componentDidMount(): void { if (__DEV__) { - if ( - !global.__RCTProfileIsProfiling && - !this.props.internal_excludeInspector - ) { + if (!this.props.internal_excludeInspector) { this._subscription = RCTDeviceEventEmitter.addListener( 'toggleElementInspector', () => { @@ -93,12 +90,10 @@ class AppContainer extends React.Component { render(): React.Node { let logBox = null; if (__DEV__) { - if (!global.__RCTProfileIsProfiling) { - if (!this.props.internal_excludeLogBox) { - const LogBoxNotificationContainer = - require('../LogBox/LogBoxNotificationContainer').default; - logBox = ; - } + if (!this.props.internal_excludeLogBox) { + const LogBoxNotificationContainer = + require('../LogBox/LogBoxNotificationContainer').default; + logBox = ; } }