Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[Discussion] Solutions to eliminate flashes caused by reloadData #2536

@nguyenhuy

Description

@nguyenhuy

So I’ve been thinking about ways to eliminate, or at least minimize, flashes caused by reloadData. This is one of the top complaints from developers that are new to the framework. I have a couple of solutions in mind and would love to start a discussion here:

  • Cell node prioritization:

    • I reckon one of the main causes of flashing is due to the fact that new cell nodes are initialized and laid out linearly, meaning they are handled from first to last index. Instead, we should have prioritized them based on the ranges. Nodes in visible range should be handled first, followed by the ones in fetch data range and so on. We can even block main thread while dealing with the highest priority nodes (i.e. visible ones).
    • One possible issue with this technique is that it needs to maintain content offset of the scroll view. In other words, we need to keep a static viewport while deleting/inserting nodes.
    • This solution maybe easier to implement once virtualization is supported, or maybe a step toward virtualization.
  • Another way to solve this problem is hiding external components (esp. the underlying table/collection view) from the fact that reloadDatais broken down into a series of deletions and insertions. What it means is that, while making changes to the data set, we don't notify ASDataControllerDelegate at all. Then once we finished loading all cells, the delegate will be notified about a single atomic reload operation.

I believe either of these solutions can eliminate the flash. Although it will make developers less likely to do batch update :(

cc @Adlai-Holler @maicki @garrettmoon @appleguy

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions