Repository navigation
Description
Description
If you try and run RNTester's integration tests after running RCT_NEW_ARCH_ENABLED=1 pod install, RNTester will crash on boot. Specifically, the crash happens when creating an RCTFabricSurface in the following method in RCTAppSetupUtils.mm:
UIView *
RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled)
{
#if RCT_NEW_ARCH_ENABLED
if (fabricEnabled) {
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
}
#endif
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
}Theory:
Unlike most apps, RNTester has Fabric enabled by default in its podfile. Most of the time, a user must manually do so by running RCT_NEW_ARCH_ENABLED=1 pod install, meaning the environment variable is passed to cocoapod, which passes it as a flag to clang when you run xcodebuild. Since RN-Tester isn't generally built with the environment variable, the flag isn't passed in everywhere (such as the method above). Indeed, I observed that running RNTesters' integration tests with a normal pod install would skip the ifdef block and return an RCTRootView in the method above!
React Native Version
main branch (as of September 20th, 2023)
Output of npx react-native info
System:
OS: macOS 14.0
CPU: (12) arm64 Apple M2 Max
Memory: 200.56 MB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.14.0
path: ~/.asdf/installs/nodejs/18.14.0/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.3.1
path: ~/.asdf/plugins/nodejs/shims/npm
Watchman:
version: 2023.09.25.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.13.0
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.19
path: /usr/bin/javac
Ruby:
version: 2.7.6
path: /Users/sanajmi/.asdf/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: false
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: true
Steps to reproduce
- Clone React-Native
- yarn install
- cd packages/rn-tester
- pod install
- cd ../..
- yarn test-ios (observe it passes)
- cd packages/rn-tester
- RCT_NEW_ARCH_ENABLED=1 pod install
- cd ../..
- yarn test-ios (Observe crash)
Snack, code example, screenshot, or link to a repository

Activity
github-actions commentedon Sep 30, 2023
github-actions commentedon Sep 30, 2023
cipolleschi commentedon Oct 2, 2023
Thanks @Saadnajmi for opening the issue.
I reproed the test failing, I think that the problem is that nobody tried to run those tests with the new architecture turned on, and, therefore, the failures.
Out of curiosity, have you ever seen them pass with the new arch turned on?
Saadnajmi commentedon Oct 2, 2023
Yeah, for 0.71 and 0.72 on React Native macOS (where we test iOS as well), we had them passing. I only got the failure in my latest merge of RNM commits to September 20th, aka, most of 0.73.
cipolleschi commentedon Oct 2, 2023
That's odd... The part of code you highlighted didn't change between 0.72 and 0.73... :/
Saadnajmi commentedon Oct 2, 2023
I want to say it's Xcode 15 related, so let me do this:
I'll try testing 0.72-stable with macOS 14+Xcode 15 and macOS 13+Xcode 14, and see if I can repro the crash on both
cortinico commentedon Oct 27, 2023
@Saadnajmi I saw two PRs related to this issue after your last comment. Can this issue be closed then?
Saadnajmi commentedon Oct 27, 2023
The two PRs are not related to this issue. But I can check the latest
main. Apologies, I have not checked against Xcode 14.3 yet. Had to downgrade an old machine..Saadnajmi commentedon Oct 28, 2023
@cortinico On
mainas of this morning, I can repro with the error with Xcode 14.3.1. I think the other memory allocation error we saw was Xcode 15 specific, so this is probably something different. I can try Xcode 14.2 or lower, but it seems to be a new issue. I think rather than test on older versions of Xcode (which involves my older, slower laptop 😅), I'll test against 0.71-stable / 0.72-stable / 0.73-stable to see if we can narrow it down more.cipolleschi commentedon Nov 7, 2023
I tried to enable the address sanitizer and the test are passing. ¯_(ツ)_/¯
Saadnajmi commentedon Nov 7, 2023
Wha... generally the opposite happens :D great!
cipolleschi commentedon Nov 8, 2023
Talking with @sammy-SC, enabling the Address Sanitizer is not a fix: this will hide an actual memory layout issue. Therefore, we are investigating what the root cause and what will be the actual fix.
cipolleschi commentedon Nov 13, 2023
Fix landing: #41441