-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Long delay (487ms+) during scrolling to load Pocket content on the homescreen; also slow on cold start #21854
Comments
One quick-to-implement optimization we could try is to split the "Thought-provoking stories" section and the "Stories by topic" section into two separate RecyclerView items. It'll also help determine if the perf problem is in the "Thought-provoking" section or the "Stories by topic" section, or both. |
Splitting the current composable from Another important aspect I think is how much of an effect does this have on the most used devices. |
The perf team picked a high-end and a low-end device that we believe is representative of our users – these are our reference devices. If we see a perf problem on our low-end reference device, we generally assume all low-end devices see similar issues. That said, we last set the reference devices in maybe 2019 so they're due for an upgrade. Those devices were the Pixel 2 (high-end) and the Moto G5 (low-end). I don't think we have time to revisit this before addressing this bug so I'm inclined to go with what I go with what I see on the Moto G5 but I'm open to discussion. fwiw, my intuition is that the Pixel 3 is closer to a high-end device amongst our user base but I haven't looked recently.
@Mugurell Just curious, why is compose slower? How did you find this out? |
Haven't profiled this myself but it seems that after all these years of being used on Android, time in which probably many improvements were made, XML layouts are really very fast. |
Though we labeled this P2, I think it's a P2 we want to track so moving to the appropriate column. |
This would shorten the time needed to layout all Pocket recommended stories content in one go, though it may lead to shorten hiccups over a bigger period of time.
There is still non-trivial jank when scrolling into the Pocket section (though it's less significant than I remember) on a Moto G5 in Nightly from 2/15: reopening. |
@mcomella @csadilek
on two versions of the debug app with the only difference being the position of the Pocket section: first at the top, then at the bottom.
Looking at the bar chart we can see the app showing the same heavy processing and framedrops when the Pocket section is at the top and then scrolling to bottom so other Views are inflated (there are also some other composables at the bottom) as when Pocket is at the bottom and the user scrolls to it to be "inflated". To me this shows that there's isn't an inherent performance issue with the Pocket section but rather with the home screen as a feature that uses RecyclerView + Android Views + Composables, a combination that proves quite heavy so to try and fix these slowdowns we should finish migrating the entire homescreen to Compose. |
The GPU rendering profile show that most of the time is spent in in the three green colors, which we have control over (here's what they represent). That doesn't tell us exactly what to optimize though a profile might get us that info. Here's a profile of scrolling down to Pocket: https://share.firefox.dev/3oU31nV and a view in that profile of the first long blocking operation https://share.firefox.dev/3v8dLTk. I don't see anything that would indicate that switching all of these views to compose will improve the performance but I'm unfamiliar with compose – e.g. maybe it's able to better batch work when it's not split between multiple RecyclerView Views. If we think that switching to all compose views would improve performance enough, we should prototype it to confirm that hypothesis. fwiw, when using the View framework, I see places where we can optimize. For example, I see we spend ~125ms inflating and populating Top Sites items on start up to homescreen https://share.firefox.dev/3oVcOd9. Instead, we could inflate the parent to a height that is based on the number of top site items (i.e. 1 row or 2?) then inflate and populate the children (the top site items) asynchronously which should speed up the initial inflation. I'm concerned we won't know how to identify optimizations, or if it's even possible to do them, with compose but again, I'm unfamiliar with it. |
@mcomella @csadilek
to compare how using just Compose on the homescreen might impact app performance. For the current implementation baseline I've also refactored HomeFragment to only show (and load data for) the same sections (in the current RecyclerView based implementation):
Results:
Haven't tested this thoroughly and the refactorings were hasted but I can upload the patches if more tests are needed. |
Thanks @Mugurell for digging into this. Given the results, and the fact that it structurally also makes more sense to move the refactoring along (compared to tweaking code that will have to be refactored anyway), I agree that this is the right approach. Let's talk offline how we can make time to move this forward. |
Thanks for doing the investigation. It looks significantly smoother when scrolling so that's great. I'm slightly concerned that the time to first frame or time to visual completeness will be longer with Compose but I assume we can optimize that (e.g. we make the initial layout only contain the logo and then add more views). fwiw, we have some perf tools that can make your investigation, and sharing your investigation, a little easier:
combined2.mp4However, in this case, take the timings in this video with a grain of salt: I don't know if this side-by-side is synchronized correctly because I can't see the action that triggered the build to start (e.g. the finger tap). |
Removing my assignment since this resulted in a meta tracking more work towards refactoring the homescreen for the future with the hope of also improving performance. |
See: #17373 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Steps to reproduce
Expected behavior
Scrolling is smooth & section appears immediately
Actual behavior
Scrolling stops as the main thread is blocked to load the Pocket content and contributes to a feeling of jank. Here's a profile: https://share.firefox.dev/3mKBZxb
According to the profile, the initial
dispatchTouchEvent
runs for 487ms (a very long time) so the delay is likely to last even longer than that. Here's a screen capture:pocket-jank.mp4
This delay also affects the cold start experience where it takes a long time to load the homescreen to visual completeness:
device-2021-10-11-113101.mp4
Device information
To address both issues raised above, I think we need to consider one or both of:
CC @Mugurell
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: