Move setStartupMetrics() to worker thread to reduce start up time of Fenix
Why/User Benefit/User Problem
Currently, every time the application starts up , we see a heavy load from setStartupMetrics() . I.e: on a 5 seconds start up time, the method can take up to 500ms (on a Moto G5+). This can mean up to 10% of load time only on setting up Metrics.
- Talking with the Glean team, it seems that we can initialize metrics on a separate threads. I'm not sure if there was a specific reason in Fenix for us to just initialize it on the UI thread.
Impact
Longer start up, means less appealing to users.
Acceptance Criteria (how do I know when I’m done?)
The method doesn't run on initialization ( or is done in a separate thread)
┆Issue is synchronized with this Jira Task
I know @hawkinsw has spent some time looking at this. You might want to connect with him to share some context!
@mcomella Based on your comment from a different issue, I know that you had some hesitations with accessing Settings off MT. We will need to address your fear before this can go forward, I think.
Though caching the results of Browsers.all() (see PR: https://github.com/mozilla-mobile/fenix/pull/7490#) will make the performance of setStartupMetrics better, I do not think that it is a bad idea to also do it asynchronously. @mcomella and @MarcLeclair, what do you think?
We spoke on Zoom: iirc, after hawkinsw's change, we noticed this affected the G5 pretty heavily but didn't affect the P2. We decided that, for now, we should focus on changes that only affect both reference devices. As such, I'm sending this back to triage.
See the WIP in https://github.com/mozilla-mobile/fenix/pull/7470 & https://github.com/mozilla-mobile/fenix/pull/7517.
Dupe https://github.com/mozilla-mobile/fenix/issues/7847