metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

chore: Improve startup times on Android through Swaps changes

Open infiniteflower opened this issue 1 year ago • 2 comments

Description

This PR removes Web3 in favor of just using Ethers to read values off a contract.

This has resulted in the following performance improvements:

With Web3 No Web3 Perf improvement
App Start 4920ms 658ms ~86% decrease
Logcat 6929ms ~2500ms ~63% decrease

App start and Logcat are 2 related but different measurements. Logcat is more closely related to visually looking at the app and seeing when it starts up.

Related issues

Fixes: https://github.com/MetaMask/metamask-mobile/issues/10611 Related to: https://github.com/MetaMask/swaps-controller/pull/293

Manual testing steps

You will need to run the QA build of the Android app onto a physical device to measure performance changes accurately.

  1. android/app/build.gradle
    1. Comment out line 3: apply plugin: "io.sentry.android.gradle"
    2. Comment out line 62 to 100 to get rid of Sentry (starts with // Sentry environment variables used by Sentry CLI to upload files. Upload is disabled by default)
    3. Line 242: change to signingConfigs.debug
  2. Connect a physical Android device to your machine.
  3. Run this command to build and install onto your physical device: cd ./android && ./gradlew assembleQaRelease -PminSdkVersion=26 -DtestBuildType=release -x app:createBundleFlaskDebugJsAndAssets && cd ../ && adb install -r android/app/build/outputs/apk/qa/release/app-qa-release.apk

Testing

  1. Start the Android app
  2. Notice how much faster it got
  3. Go to Swaps
  4. Select From token as an ERC20 which requires allowance
  5. Get a quote
  6. Notice Edit Limit
    1. Select From token as an ERC20 which doesn't requires allowance
  7. Get a quote
  8. Notice Edit Limit is not there

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

infiniteflower avatar Aug 23 '24 19:08 infiniteflower

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

github-actions[bot] avatar Aug 23 '24 19:08 github-actions[bot]

Resolved already

Cal-L avatar Sep 04 '24 18:09 Cal-L

@Cal-L We still need this PR for when we bump SwapsController to v10, If we could keep it open that would be great.

infiniteflower avatar Sep 04 '24 21:09 infiniteflower