Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats Period / Stats Traffic: Improve scrolling performance #22721

Open
staskus opened this issue Feb 28, 2024 · 4 comments · May be fixed by #22847
Open

Stats Period / Stats Traffic: Improve scrolling performance #22721

staskus opened this issue Feb 28, 2024 · 4 comments · May be fixed by #22847

Comments

@staskus
Copy link
Contributor

staskus commented Feb 28, 2024

The Stats Traffic tab's scrolling performance still stutters, even on iPhone 14 Pro. There may be some inefficiencies in how cells are built:

  1. Timebox an improvement task (e.g. 1 day)
  2. Use Animation Hitches and/or TimeProfiler to identify the most inefficient reloads
  3. Try to make improvements to the most inefficient reloads
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 28, 2024

Thanks for reporting! 👍

@guarani
Copy link
Contributor

guarani commented Feb 28, 2024

Thanks! I also see the stuttering during pull-to-refresh on the Traffic tab or the Insights tab.

@staskus staskus self-assigned this Mar 13, 2024
@staskus
Copy link
Contributor Author

staskus commented Mar 14, 2024

Analysis

Hitches can be identified using Animation Hitches Instrument.

Apple classifies Hitches as:

  • Critical if the hitch lasts longer than 10ms per second
  • Warning if the hitch lasts between 5 to 10ms per second
  • Good if the hitch lasts less than 5 ms per second
image

I ran Hitches instrument on iPhone 14 Pro by loading Traffic tab on a high-traffic site and scrolling up and down a couple of times. I repeated the testing cycle a few times to see if the same issues were consistently reported.

TopTotalsCell

TopTotalsCell activity was seen most frequently before the hitch was reported.

image

TopTotalsCell is highly configurable and used for fileDownloadsTableRows, videosTableRows, postsAndPagesTableRows, referrersTableRows, clicksTableRows, authorsTableRows, searchTermsTableRows.

TimeProfiler indicates issues with:

  • UITableViewCell addRows() extension calls
  • TopTotalsCell setSubtitleVisibility calls

At each configuration, cells add and remove nested UIStackViews and its rows. The hitch can be seen live when scrolling on the device. Right before a new cell appears, scrolling stutters for a second. If we remove this nested stack view configuration, the stutter disappears.

CountriesCell & CountriesMapCell

image

Before the Country row with a map appears, a small stutter can be experienced on the device which is also registered by Hitches instrument. Time Profiler indicates couple of issues:

  • CountriesMapCell setting countriesMapView on a UIStackView which in turn loads a 3rd party FSInteractiveMapView
  • Similar issues to TopTotalsCell: CountriesCell making UITableViewCell addRows() extension calls, setSubtitleVisibility calls

BottomScrollAnalytics

Minor Animation Hitches are also reported around the time calls to analytics are made. ImmuTableHandler observes scrollViewWillEndDragging to report trackScrollToBottomEvent. This particular event is not required for StatsTraffic feature and could be removed. Since it's reported when the bottom of the scroll view is reached, it's unlikely this call contributes to any visible stutter. It's worth re-running Hitches instrument after other more impactful issues are resolved to see if stutters are still visible and if Hitches are still reported around analytics calls.

Next Step

UIStackView usage needs to be optimized since it looks to be the main reason that causes stutters when scrolling Stats table view. It affects most of the available rows due to UITableViewCell addRows() calls being made. I already started doing some optimization work and hope to make improvements.

@guarani
Copy link
Contributor

guarani commented Mar 15, 2024

I'm just letting you know I'm reorganizing the "Performance improvements" issues and moved them to a new GitHub project. I will clarify this over Slack.

@staskus staskus linked a pull request Mar 18, 2024 that will close this issue
14 tasks
@staskus staskus changed the title Stats Traffic: Improve scrolling performance Stats Period / Stats Traffic: Improve scrolling performance Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants