chore: Improve startup times on Android through Swaps changes
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.
-
android/app/build.gradle- Comment out line 3:
apply plugin: "io.sentry.android.gradle" - 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) - Line 242: change to
signingConfigs.debug
- Comment out line 3:
- Connect a physical Android device to your machine.
- 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
- Start the Android app
- Notice how much faster it got
- Go to Swaps
- Select From token as an ERC20 which requires allowance
- Get a quote
- Notice Edit Limit
-
- Select From token as an ERC20 which doesn't requires allowance
- Get a quote
- Notice Edit Limit is not there
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I’ve followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [x] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using JSDoc format if applicable
- [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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.
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.
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
| Package | New capabilities | Transitives | Size | Publisher |
|---|---|---|---|---|
| npm/@types/[email protected] | None | 0 |
22.1 kB | types |
| npm/[email protected] | network | 0 |
75.1 kB | lquixada |
| npm/[email protected] | None | 0 |
38 kB | lpinca |
🚮 Removed packages: npm/@adraffy/[email protected]), npm/@metamask/[email protected]), npm/@types/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected]), npm/[email protected])
Resolved already
@Cal-L We still need this PR for when we bump SwapsController to v10, If we could keep it open that would be great.