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

feat(Android): optimize app installation. #3195

Merged
merged 48 commits into from
Jul 18, 2022

Conversation

jonathanmos
Copy link
Contributor

@jonathanmos jonathanmos commented Jan 30, 2022

Description

Resolves #3175
Resolves #2537

Implemented only for Android.

  1. Improve APK install time by:
    • taking a hash of the binary that is being installed and writing it to the emulator as file whose filename is the binary name.
    • on the next install, checks whether the hash exists and if it does then clear user data without performing uninstall/install.
  2. Adds a new method of resetAppState to decide between clearing user data and reinstallation.
  3. Adds a boolean option to Detox behavior config, optimizeAppInstall with a corresponding CLI flag: --optimize-app-install.

In terms of performance: uninstall/install takes 6-7s, whereas clearing app state takes 400-600ms.

This pull request fixes #2534 .

For API changes:

  • [X ] I have made the necessary changes in the types index file.

Copy link
Collaborator

@d4vidi d4vidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey hey,
this is going in a good direction but requires more work, still. We will run over this through several iterations.

Besides my comments, please be sure to also provide details regarding the positive impact this has over the overall execution time. I urge you to utilize the timeline artifact in order to be able to do that...

🙏🏻

detox/src/devices/common/drivers/android/tools/FileXfer.js Outdated Show resolved Hide resolved
detox/src/devices/common/drivers/android/tools/FileXfer.js Outdated Show resolved Hide resolved
detox/src/devices/runtime/drivers/android/AndroidDriver.js Outdated Show resolved Hide resolved
detox/test/integration/stub/StubRuntimeDriver.js Outdated Show resolved Hide resolved
detox/src/devices/runtime/drivers/ios/SimulatorDriver.js Outdated Show resolved Hide resolved
detox/src/devices/runtime/drivers/android/AndroidDriver.js Outdated Show resolved Hide resolved
@jonathanmos jonathanmos changed the title [WIP] Improve apk install on android Improve apk install on android Feb 13, 2022
Copy link
Collaborator

@d4vidi d4vidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress but it's still not ready for merge. Please see my notes, especially the one regarding the external API changes.

detox/src/devices/common/drivers/android/exec/ADB.js Outdated Show resolved Hide resolved
detox/src/devices/runtime/drivers/android/AndroidDriver.js Outdated Show resolved Hide resolved
detox/src/devices/common/drivers/android/tools/FileXfer.js Outdated Show resolved Hide resolved
@d4vidi d4vidi force-pushed the improve-apk-install-attempt2 branch from 7168e33 to 0285e55 Compare March 1, 2022 13:39
# Conflicts:
#	detox/src/Detox.js
#	detox/src/Detox.test.js
#	docs/APIRef.DetoxCLI.md
@asafkorem asafkorem changed the title feat: optimize app installation feat(Android): optimize app installation. Jul 14, 2022
@asafkorem asafkorem self-assigned this Jul 14, 2022
@asafkorem
Copy link
Contributor

Starting a review.

Copy link
Contributor

@asafkorem asafkorem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good game 🥇

detox/index.d.ts Outdated Show resolved Hide resolved
detox/index.d.ts Outdated Show resolved Hide resolved
detox/index.d.ts Outdated Show resolved Hide resolved
detox/index.d.ts Show resolved Hide resolved
detox/local-cli/test.js Show resolved Hide resolved
detox/src/servicelocator/android/index.js Outdated Show resolved Hide resolved
detox/src/servicelocator/android/index.js Outdated Show resolved Hide resolved
detox/test/e2e/detox.config.js Outdated Show resolved Hide resolved
@@ -28,6 +28,7 @@ describe("Test", () => {

beforeAll(async () => {
await device.reloadReactNative();
await device.resetAppState();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why here? @noomorph / @jonathanmos

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asafkorem it is not a test per se, it is a typing/compiler error check thing.

docs/APIRef.DetoxCLI.md Outdated Show resolved Hide resolved
Copy link
Contributor

@asafkorem asafkorem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Merge once CI passes 🎖️

@jonathanmos jonathanmos merged commit 9221257 into master Jul 18, 2022
@jonathanmos jonathanmos deleted the improve-apk-install-attempt2 branch July 18, 2022 20:56
}

async readFile(deviceId, filepath, silent = false) {
if (silent) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never seems to be called with silent=false. Is this really necessary?
@jonathanmos

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to allow for calling nonsilently in future. Atm it's called only from the optimized flow

jonathanmos added a commit that referenced this pull request Jul 20, 2022
jonathanmos added a commit that referenced this pull request Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants