-
Notifications
You must be signed in to change notification settings - Fork 907
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
feat: add option to build only active architectures on android #1388
feat: add option to build only active architectures on android #1388
Conversation
That's just raised a question for me - does |
@liamjones This is configured in xcode and I think is enabled by default. You can verify in your project settings here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @grabbou mind having a look and releasing a minor version when merged?
Yup, this is the default on iOS. Thanks @janicduplessis for the PR and for the explanation - my first question was why we don't turn it by default, and I guess we can do it in a follow-up release or when it becomes more widely spread. |
Can probably turn it on by default on by default. I've been using this for a while without issues. I try to get the RN part merged so this can work, maybe target next RN release 0.66. |
Summary: Building from source in debug takes a very long time because native builds need to run for all supported architectures. It is possible to check which architecture the devices for which we are about to launch the app on are and build only for those. For most cases we can reduce the number of architectures we build for to 1 instead of 4, resulting in a large speedup of the build. This is inspired by iOS which has a "Build for active architecture only" option. Since android doesn't really support this natively we can implement it here and also in react-native by reading the build properties that we pass and alter the abi we build for. With fabric / codegen coming up I suspect that we might want to default to building c++ soon. This should ease the transition as builds won't be orders of magnitude slower. See react-native-community/cli#1388 for more context and how we use this new config to automatically detect running emulator architectures. ## Changelog [Android] [Added] - Allow configuring ndk build architectures Pull Request resolved: #31232 Test Plan: Tested by setting reactNativeDebugArchitectures with different values in gradle.properties. Checked the build logs to see which architectures are being built. Also made sure release builds are not affected by this value. Clean build reactNativeDebugArchitectures not set 824.41s reactNativeDebugArchitectures=x86 299.77s Reviewed By: mdvacca Differential Revision: D29613939 Pulled By: ShikaSD fbshipit-source-id: d20a23d1d9bbf33f5afaaf3475f208a2e48c0e1a
Summary: I've unified the function that is responsible of getting the `reactNativeArchitectures` property to a single one (ideally we could move it inside the Gradle Plugin in the future). I've also added a property in the `gradle.properties` file. This makes easier for users to customize the architecture to build without having to specify a CLI flag or edit multiple gradle files. Changelog: [Android] [Added] - Make the `reactNativeArchitectures` property more discoverable Reviewed By: ShikaSD Differential Revision: D32244997 fbshipit-source-id: 33180544400f9abe63e9b539ff16fefa17a024ba
Summary:
Building from source in debug takes a very long time because native builds need to run for all supported architectures. It is possible to check which architecture the devices for which we are about to launch the app on are and build only for those. For most cases we can reduce the number of architectures we build for to 1 instead of 4, resulting in a large speedup of the build.
This is inspired by iOS which has a "Build for active architecture only" option. Since android doesn't really support this natively we can implement it here and also in react-native by reading the build properties that we pass and alter the abi we build for.
With fabric / codegen coming up I suspect that we might want to default to building c++ soon. This should ease the transition as builds won't be orders of magnitude slower.
For now this is enabled only behind a flag, I think this is better since for the common case of not building from source this change doesn't have any effect. If RN moves to building c++ by default on android we can consider changing the default.
RN PR to add support for reactNativeDebugArchitectures: facebook/react-native#31232
Test Plan:
Tested this change + an incoming PR to the react-native repo with a combinaison of simulators and physical devices. Checked the build logs to see which architectures are being built.
Clean build for x86 simulator
react-native run-android
824.41s
react-native run-android --active-arch-only
299.77s