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

perf: remove Gradle task check on run-android #2144

Conversation

TMisiukiewicz
Copy link
Collaborator

@TMisiukiewicz TMisiukiewicz commented Oct 31, 2023

Summary:

Related: #2012
When running run-android command, it takes a lot of time to build the app for more complex projects with lots of dependencies and different flavors. It is caused by the code checking if the task for provided mode exists. Under the hood, it's running ./gradlew tasks which takes a lot of time. A good example of such complex project is Expensify App, where delay in building the app takes ~4mins.

Here is a screenshot from profiling report of ./gradlew tasks --group install from Expensify :
image

This PR removes this check - Gradlew itself throws an error if the task for provided mode does not exist so we can rely on that:

FAILURE: Build failed with an exception.

* What went wrong:
Cannot locate tasks that match 'app:installAaa' as task 'installAaa' not found in project ':app'.

Additionally, getting task list should still exist in the interactive mode. Unfortunately in more complex projects, it might stil take a lot of time to execute. A note about it was added to the docs. As a DX improvement, I added the loader indicating that the process is currently looking for Gradle tasks.

Test Plan:

  1. Run node path/to/cli run-android
  2. Verify after starting Metro and simulator it moved to building the app immediately
  3. Run node path/to/cli run-android --mode Aaa
  4. Verify it throws an error from Gradle
  5. Run node path/to/cli run-android --interactive
  6. Verify it shows loader "Searching for available gradle tasks..." before prompting to select the task

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@github-actions github-actions bot added the docs Documentation change label Oct 31, 2023
@cortinico
Copy link
Member

This PR removes this check

Love this :)

@thymikee thymikee merged commit 1167de7 into react-native-community:main Oct 31, 2023
6 checks passed
@szymonrybczak
Copy link
Collaborator

We should backport this to 0.72 cc. @thymikee

thymikee pushed a commit that referenced this pull request Oct 31, 2023
* remove gradle task check on run-android

* add loader and README note

* throw error when no tasks found
@thymikee
Copy link
Member

@szymonrybczak here: #2145

thymikee added a commit that referenced this pull request Nov 3, 2023
* remove gradle task check on run-android

* add loader and README note

* throw error when no tasks found

Co-authored-by: Tomasz Misiukiewicz <TMisiukiewicz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants