MetaMask / MetaMask/metamask-mobile
Investigate and improve App startup time on Android (decrease P75 from 3s to 2s)
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
### What is this about?
Currently, Android application starts 2-3 times slower than iOS:
[Android dashboard](https://metamask.sentry.io/explore/discover/results/?display=bar&environment=production&field=p50%28transaction.duration%29&field=p75%28transaction.duration%29&field=p95%28transaction.duration%29&name=UI%20Startup%20%28Android%29&project=2299799&query=release.package%3Aio.metamask%20transaction%3A%22UI%20Startup%22&queryDataset=transaction-like&statsPeriod=30d&yAxis=p50%28transaction.duration%29&yAxis=p75%28transaction.duration%29&yAxis=p95%28transaction.duration%29)
[iOS dashboard to compare](https://metamask.sentry.io/explore/discover/results/?display=bar&environment=production&field=p50%28transaction.duration%29&field=p75%28transaction.duration%29&field=p95%28transaction.duration%29&name=UI%20Startup%20%28iOS%29&project=2299799&query=release.package%3Aio.metamask.MetaMask%20transaction%3A%22UI%20Startup%22&queryDataset=transaction-like&statsPeriod=30d&yAxis=p50%28transaction.duration%29&yAxis=p75%28transaction.duration%29&yAxis=p95%28transaction.duration%29)
The goal of this task is to identify the reasons behind it and improve P75 start time **from 3 seconds to 2 seconds** (33% improvement).
### Potential findings:
1) When application starts, there are multiple IO operations going on the same thread (Accessing multiple variables from MMKV, Reading 660kb file InpageBridgeWeb3.js). Potentially, we can delay some of them at least until PIN UI is displayed to the user.
2) When app is started and PIN screen is displayed, underneath the browser component is immediately loaded with many heavy dependencies and operations. Could be also delayed until the PIN screen is displayed.
3) On Login and Onboarding screens we load Lottie animations which are extremely heavy. Login screen loads two animations with total weight 3.6mb. Animations should be at least [compressed](https://tiny-lottie-nextjs.vercel.app) or converted to [dotLottie](https://www.npmjs.com/package/@lottiefiles/dotlottie-react-native).
### Scenario
_No response_
### Design
_No response_
### Technical Details
### Steps to do:
1) Implement Android [Macrobenchmark](https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview) for two scenarios: launching the app in onboarding and launching the app for logined user
2) Identify bottlenecks (start from Potential findings section above)
3) Resolve these bottlenecks
4) Implement [baseline profile](https://developer.android.com/topic/performance/baselineprofiles/overview)
5) Measure old and new time to see the result
### Threat Modeling Framework
_No response_
### Acceptance Criteria
P75 Startup time is decreased from 3 seconds to 2 seconds.
### Stakeholder review needed before the work gets merged
- [ ] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
### References
_No response_
Contributor guide
Research direction
Start by reading the linked Android Macrobenchmark and baseline profile documentation, then implement benchmarks for onboarding and logged-in launches. Investigate the listed IO operations, browser loading, and Lottie animations, and compare the old and new P75 measurements; done means reducing startup P75 from 3 seconds to 2 seconds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, react-native, typescript
- Domain
- mobile-dev, performance, testing-qa
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100