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

LOW: Migrate the main chat list to FlashList #33725

Open
roryabraham opened this issue Dec 28, 2023 · 20 comments
Open

LOW: Migrate the main chat list to FlashList #33725

roryabraham opened this issue Dec 28, 2023 · 20 comments
Assignees
Labels
Monthly KSv2 NewFeature Something to build that is a new item.

Comments

@roryabraham
Copy link
Contributor

HOLD on:

  • Comment linking to be 100% complete
  • The new architecture to be enabled (this is not a hard requirement but I have a hunch that this should wait on that too)

Problem

The main chat list is one of the most, if not the most important component in our app. If you scroll far or fast on this list, you may see frames drop. Furthermore, there are some known performance issues with this list (example). We have already migrated almost every other virtualized list in our app from FlatList to FlashList, because its performance is much better.

Solution

Let's build support for bidirectional pagination in FlashList, then enable it on the main chat list in E/App.

@roryabraham roryabraham added Monthly KSv2 NewFeature Something to build that is a new item. labels Dec 28, 2023
@roryabraham roryabraham self-assigned this Dec 28, 2023
Copy link

melvin-bot bot commented Dec 28, 2023

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Monthly KSv2 labels Dec 28, 2023
@roryabraham
Copy link
Contributor Author

I expect this to be on HOLD until sometime in February, if not later, so I'm moving this back to monthly

@roryabraham roryabraham added Monthly KSv2 and removed Weekly KSv2 labels Dec 28, 2023
@roryabraham
Copy link
Contributor Author

cc @muttmuure adding this to the New Expensify performance improvements project. I acknowledge that the problem statement is a bit of a reverse-solution but I think it's a good bet that this will provide substantial performance improvements, as FlashList is just much better for performance than FlatList. We've established that elsewhere where we've migrated to FlashList

@roryabraham
Copy link
Contributor Author

Still on HOLD

@melvin-bot melvin-bot bot added the Overdue label Feb 19, 2024
@roryabraham
Copy link
Contributor Author

on HOLD for comment linking

@roryabraham
Copy link
Contributor Author

roryabraham commented Mar 25, 2024

HOLD, but could come off HOLD soon. Unclear if we'll prioritize

@melvin-bot melvin-bot bot removed the Overdue label Mar 25, 2024
@melvin-bot melvin-bot bot added the Overdue label Apr 25, 2024
@garrettmknight
Copy link
Contributor

@roryabraham we good to take this off hold? If so, where do you think it might fit in a wave, if any? I'm not 100% on the significance of this migration beyond general, better performance.

@melvin-bot melvin-bot bot removed the Overdue label Apr 26, 2024
@roryabraham
Copy link
Contributor Author

Good question. As far as I know there's no significance beyond general, better performance of chat screens.

@quinthar quinthar changed the title [HOLD] Migrate the main chat list to FlashList LOW: [HOLD] Migrate the main chat list to FlashList May 12, 2024
@perunt
Copy link
Contributor

perunt commented May 13, 2024

@roryabraham, you’re absolutely right about the performance perks we’d get with FlashList—better speed, faster rendering, the whole deal. But there's a bit of a twist when it comes to the bidirectional scrolling we need. Right now, adding that feature to FlashList can lead to some choppy experiences. It might slow us down a bit to get that smoothed out.

There is a PR with the implementation of a bidirectional list, but it is a bit stale (Shopify/flash-list#824)
also would be nice to double-check this approach (https://github.com/irisjae/recyclerlistview/blob/master/README.md). This guy added something called preserveVisiblePosition, which claims to fix those choppy scrolling issues. I haven't tried it yet, but worth to try

@garrettmknight garrettmknight changed the title LOW: [HOLD] Migrate the main chat list to FlashList [HOLD] LOW: Migrate the main chat list to FlashList Jun 10, 2024
@garrettmknight
Copy link
Contributor

Still on hold.

@melvin-bot melvin-bot bot removed the Overdue label Jun 10, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 11, 2024
@garrettmknight
Copy link
Contributor

@roryabraham any idea where this fits priority wise?

@melvin-bot melvin-bot bot removed the Overdue label Jul 12, 2024
@muttmuure
Copy link
Contributor

I think this can come off hold now?

@melvin-bot melvin-bot bot added the Overdue label Aug 12, 2024
@garrettmknight
Copy link
Contributor

@roryabraham can this come of hold?

@melvin-bot melvin-bot bot removed the Overdue label Aug 13, 2024
@roryabraham roryabraham changed the title [HOLD] LOW: Migrate the main chat list to FlashList LOW: Migrate the main chat list to FlashList Aug 27, 2024
@muttmuure
Copy link
Contributor

@janicduplessis is going to investigate this

@janicduplessis
Copy link
Contributor

I will take this :)

@janicduplessis
Copy link
Contributor

After first investigation of this there are 2 main things we need to implement:

  1. Support onStartReached. This one is pretty simple, I already have a working prototype.
  2. Support maintainVisibleContentPosition (or some alternative implementation that does the same thing). I found why maintainVisibleContentPosition does not work with FlashList, it has to do with the view hierarchy it creates. The maintainVisibleContentPosition implementation assumes ScrollView -> ContentView -> Cells, but FlashList creates ScrollView -> ContentView -> AutoLayout -> Cells.

For #2 I am currently investigating the different approaches we can use to fix this.

@roryabraham
Copy link
Contributor Author

I'm headed on parental leave. @mountiny going to reassign to you as this is part of #newdot-quality.

@roryabraham roryabraham assigned mountiny and unassigned roryabraham Oct 4, 2024
@mountiny
Copy link
Contributor

mountiny commented Oct 7, 2024

@janicduplessis How is this one looking? What are the next steps and ETA?

@janicduplessis
Copy link
Contributor

Picking up work on this this week. Will provide another update and ETA soon.

@janicduplessis
Copy link
Contributor

Update: I abandoned the maintainVisibleContentPosition route as it isn't really compatible with how recyclerlistview handles virtualization.

Instead I am currently looking at using a redesigned version of flash-list / recyclerlistview, the changes made are described in details here (really suggest going through it, very interesting). In summary it changes the virtualization algorithm to have first class support for keeping the visible content position.

I managed to get it working in expensify app, the main work needed was to get it working on new arch and add support for onStartReached. It seem to work really well except for a pretty big flicker when it adjusts the position of items in one case. I have some ideas on how to fix this. I am pretty optimistic that this is a great solution and will continue working in that direction.

Will post some demo and code later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monthly KSv2 NewFeature Something to build that is a new item.
Projects
Development

No branches or pull requests

6 participants