Skip to content

[iOS] RNTester fails Integration tests with RCT_NEW_ARCH_ENABLED=1  #39719

Closed

Description

@Saadnajmi

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

  1. Clone React-Native
  2. yarn install
  3. cd packages/rn-tester
  4. pod install
  5. cd ../..
  6. yarn test-ios (observe it passes)
  7. cd packages/rn-tester
  8. RCT_NEW_ARCH_ENABLED=1 pod install
  9. cd ../..
  10. yarn test-ios (Observe crash)

Snack, code example, screenshot, or link to a repository

Screenshot 2023-09-29 at 8 20 47 PM

Activity

  1. added
    Type: New Architecture
    on Sep 30, 2023
  2. github-actions commented on Sep 30, 2023

    @github-actions
    ⚠️ Add or Reformat Version Info
    ℹ️ We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
  3. github-actions commented on Sep 30, 2023

    @github-actions
    ⚠️ Missing Reproducible Example
    ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
    • If your bug is UI related: a Snack
    • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
  4. added
    Platform: iOS
    Needs: Repro
    on Sep 30, 2023
  5. cipolleschi commented on Oct 2, 2023

    @cipolleschi
    Contributor

    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?

  6. Saadnajmi commented on Oct 2, 2023

    @Saadnajmi
    ContributorAuthor

    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.

    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?

  7. added
    Needs: Attention
    and removed on Oct 2, 2023
  8. cipolleschi commented on Oct 2, 2023

    @cipolleschi
    Contributor

    That's odd... The part of code you highlighted didn't change between 0.72 and 0.73... :/

  9. Saadnajmi commented on Oct 2, 2023

    @Saadnajmi
    ContributorAuthor

    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

  10. cortinico commented on Oct 27, 2023

    @cortinico
    Contributor

    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

    @Saadnajmi I saw two PRs related to this issue after your last comment. Can this issue be closed then?

  11. Saadnajmi commented on Oct 27, 2023

    @Saadnajmi
    ContributorAuthor

    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

    @Saadnajmi I saw two PRs related to this issue after your last comment. Can this issue be closed then?

    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..

  12. Saadnajmi commented on Oct 28, 2023

    @Saadnajmi
    ContributorAuthor

    @cortinico On main as 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.

  13. cipolleschi commented on Nov 7, 2023

    @cipolleschi
    Contributor

    I tried to enable the address sanitizer and the test are passing. ¯_(ツ)_/¯

  14. Saadnajmi commented on Nov 7, 2023

    @Saadnajmi
    ContributorAuthor

    I tried to enable the address sanitizer and the test are passing. ¯_(ツ)_/¯

    Wha... generally the opposite happens :D great!

  15. cipolleschi commented on Nov 8, 2023

    @cipolleschi
    Contributor

    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.

  16. cipolleschi commented on Nov 13, 2023

    @cipolleschi
    Contributor

    Fix landing: #41441

  17. added
    Resolution: PR Submitted
    and removed
    Needs: Repro
    on Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Needs: AttentionPartnerPlatform: iOSResolution: PR SubmittedType: New Architecturep: Microsoft

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions