Skip to content

Commit 796d182

Browse files
lokshunhungmeta-codesync[bot]
authored andcommitted
Add missing INIT_REACT_RUNTIME_START and APP_STARTUP_START in loadScript (facebook#54255)
Summary: Resolves facebook#53818 On a freshly init bare react native project, upon booting up the iOS simulator, the logs shows the following warnings: ``` Unbalanced calls start/end for tag 20 Unbalanced calls start/end for tag 19 ``` The detailed cause is explained in [this comment in the issue thread](facebook#53818 (comment)), and I'm copying it here for ease of reading: > The `Unbalanced calls start/end for tag 20` message comes from [RCTPerformanceLogger.markStartForTag](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/React/Base/RCTPerformanceLogger.mm#L78) > > 19 represents `RCTPLAppStartup` case of `RCTPLTag` (react performance logger tag), and 20 represents `RCTPLInitReactRuntime` > > In C++, they are also referred to as `ReactMarker::APP_STARTUP_STOP` and `ReactMarker::INIT_REACT_RUNTIME_STOP` respectively (see [here](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTPerformanceLoggerUtils.mm#L21) and [here](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/React/CxxBridge/RCTCxxBridge.mm#L116)) > > The performance logger logs these "stop" events inside [ReactInstance::loadScript](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L270-L271). > > Notice that [L267-272](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L267-L272), we have: > ``` > if (hasLogger) { > ReactMarker::logTaggedMarkerBridgeless( > ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); > ReactMarker::logMarkerBridgeless(ReactMarker::INIT_REACT_RUNTIME_STOP); > ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP); > } > ``` > > But earlier in [L241-244](https://github.com/facebook/react-native/blob/2d980558a616d13c542a1d0f8659beb04d31ab08/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L241-L244), we have: > ``` > if (hasLogger) { > ReactMarker::logTaggedMarkerBridgeless( > ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); > } > ``` ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [FIXED] - Address unexpected warning about "Unbalanced calls start/end for tag 20/19" Pull Request resolved: facebook#54255 Test Plan: Steps to reproduce are described by original issue reporter [here](facebook#53818 (comment)). The issue surfaced in a freshly init bare react native project 1. Create a bare react-native project 2. Run iOS simulator 3. "Unbalanced calls start/end for tag 20/19" does not show up in Xcode terminal Reviewed By: javache Differential Revision: D85421729 Pulled By: cipolleschi fbshipit-source-id: f80c0dd18e1d4817b1111af29ca516b494742d5a
1 parent 0cadb8c commit 796d182

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ void ReactInstance::loadScript(
241241
if (hasLogger) {
242242
ReactMarker::logTaggedMarkerBridgeless(
243243
ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
244+
ReactMarker::logMarkerBridgeless(ReactMarker::INIT_REACT_RUNTIME_START);
245+
ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_START);
244246
}
245247

246248
// Check if the shermes unit is avaliable.

0 commit comments

Comments
 (0)