Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2x slower android builds after upgrading to 0.76 #48316

Closed
ethanneff opened this issue Dec 17, 2024 · 5 comments
Closed

2x slower android builds after upgrading to 0.76 #48316

ethanneff opened this issue Dec 17, 2024 · 5 comments
Labels
Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@ethanneff
Copy link

ethanneff commented Dec 17, 2024

Description

Our Android builds are significantly slower after upgrading from 0.75.4 to 0.76.5

Screenshot 17

A large amount of time is doing C work because of the new architecture. Is this expected?

  • 2024-12-17T09:09:48.5675575Z [09:09:48]: ▸ [35m> Task :app:buildCMakeRelWithDebInfo[arm64-v8a][0m 4 minutes
  • 2024-12-17T09:14:01.6679960Z [09:14:01]: ▸ [35m> Task :app:buildCMakeRelWithDebInfo[armeabi-v7a][0m 2 minutes
  • 2024-12-17T09:17:40.9667954Z [09:17:40]: ▸ �[35m> Task :app:configureCMakeRelWithDebInfo[x86]�[0m 30 seconds
  • 2024-12-17T09:18:10.8667528Z [09:18:10]: ▸ [35m> Task :app:buildCMakeRelWithDebInfo[x86][0m 2 minutesa

Steps to reproduce

  1. run ./gradlew assembleRelease assembleDebug on a react native without framework
  2. compare 0.75.4 speeds to 0.76.5 speeds

React Native Version

0.76.5

Affected Platforms

Runtime - Android

Areas

JSI - Javascript Interface, Codegen

Output of npx react-native info

❯ npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 15.1.1
  CPU: (12) arm64 Apple M3 Pro
  Memory: 279.53 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.0
    path: ~/.nvm/versions/node/v20.12.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.12.0/bin/yarn
  npm:
    version: 10.8.2
    path: ~/Documents/adaptedmind/AdaptedMindMobile/node_modules/.bin/npm
  Watchman:
    version: 2024.09.23.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK:
    API Levels:
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 35.0.0
    System Images:
      - android-30 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.1
    path: /Users/eneff/.rvm/rubies/ruby-3.3.1/bin/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: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true


### Stacktrace or Logs


before

https://gist.github.com/ethanneff/581ae74c327fe18f65c792d622a08640

after

https://gist.github.com/ethanneff/2eb0b8e8196f209834e147b5f0c95ed3

### Reproducer

https://github.com/facebook/react-native

### Screenshots and Videos

attached
@ethanneff ethanneff added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Dec 17, 2024
@react-native-bot react-native-bot added Platform: Android Android applications. Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Dec 17, 2024
@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@cipolleschi
Copy link
Contributor

@ethanneff Yes, this is expected. The New Architecture is written in C++ a lot of the code is written with that language.

That's also why we ship prebuilds for React Native on Android. Regular apps does not have to rebuild React Native for Android and the build time is in the order or a few minutes.

I assume that you are building React Native from source. Can I ask you why? Why do you have to maintain a fork of React Native instead of consuming the prebuilds?

@lovegaoshi
Copy link

I personally see a 30% increase in build time on android (20min old arch vs 27min new) the only difference is simply newarch=true.

My previous experience building rn from source with the default github actions runners takes ~1h.

@cipolleschi
Copy link
Contributor

@lovegaoshi I'm not that big of an expert of Android build system, we should wait for @cortinico to be back. However, it would help if you can share your gradle logs to understand where the build is taking more time.

In theory, if you don't have custom C++ code and you are consuming prebuilds from react native, the build time should not increase that much.

@cortinico
Copy link
Contributor

@ethanneff Yes, this is expected. The New Architecture is written in C++ a lot of the code is written with that language.

As @cipolleschi mentioned, the New Architecture relies on C++ for component/module registration, so there is another compiler to run, link, etc. So yes is expected that building could be a bit slower than Old Arch.

However I see from your build log that you're building all the Native Architectures: armeabi-v7a,arm64-v8a,x86,x86_64.

The suggestion is to build only the architecture you need (generally arm64-v8a is sufficient), and build all of them only once you need to publish to a store.

You can also consider using caching (such as ccache or the setup-gradle GitHub Action to speed up your build step) on CI.

You can read more about it here: https://reactnative.dev/docs/next/build-speed

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

5 participants