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

Remember offset of collection views during table view reload to avoid jitter #5959

Closed
wants to merge 1 commit into from

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Apr 1, 2022

Fixes #5958

There are a number of reasons why the home screen keeps jitterring (especially with lots of data), but fundamentally they have to do with:

  1. Refreshing the entire home screen way too often
  2. Not restoring content offsets of collection views when table view is reloaded

To expand on this, home screen table view contains row items, which themselves contain individual collection views. When we reload the table view, the usual data source methods for creating a cell will be called, which creates any given collection view by dequeing it from the table view's pool. This means that if there are multiple collection views, they may be arbitrarily and randomly swapped around and repurposed for different sections, whilst not resetting their content offset. This, I think, is one major downside to nesting table views and collection views (note, this isn't an issue with nested scrollviews).

We could simply reset content offset each time prepareForReuse is called (and this is indeed added now), but this on its own is not enough, given the frequency of home screen reloads (on heavy accounts this happens 20-30 times per second). The outcome of this change only would be constant resetting of each collection view to its start, i.e. another inability to scroll.

Whilst a more thorough refactor of the data source and frequency of refreshes is necessary (and will be done as part of #5619), the solution presented here will store current content offsets for each collection view before a table view is reloaded, and then restored immediately afterwards. Whilst we are still refreshing far too many times, and collection views are randomly getting swapped around, at least it should not be visually jarring anymore.

A more thorough refactor of the data source will follow.

@Anderas Anderas requested review from a team and SBiOSoftWhare and removed request for a team April 1, 2022 14:17
@github-actions
Copy link

github-actions bot commented Apr 1, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/72tiP5

@Anderas Anderas closed this Apr 4, 2022
@Anderas Anderas closed this Apr 4, 2022
@Anderas Anderas deleted the andy/5958_home_scroll branch April 4, 2022 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restore collection view offsets after table view reload
1 participant