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

HIGH: Migrate the main chat list to FlashList #33725

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

HIGH: Migrate the main chat list to FlashList #33725

roryabraham opened this issue Dec 28, 2023 · 26 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
@quinthar quinthar moved this from MEDIUM to LOW in [#whatsnext] #quality May 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.

@muttmuure
Copy link
Contributor

@janicduplessis how is this going?

@janicduplessis
Copy link
Contributor

I've been working on some other tasks, but should be good to come back on this soon.

@muttmuure muttmuure moved this from LOW to CRITICAL in [#whatsnext] #quality Nov 12, 2024
@muttmuure muttmuure moved this from CRITICAL to LOW in [#whatsnext] #quality Nov 12, 2024
@muttmuure muttmuure moved this from LOW to HIGH in [#whatsnext] #quality Nov 19, 2024
@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
@mountiny
Copy link
Contributor

mountiny commented Dec 2, 2024

@janicduplessis @hannojg any updates here?

@melvin-bot melvin-bot bot removed the Overdue label Dec 2, 2024
@muttmuure muttmuure changed the title LOW: Migrate the main chat list to FlashList HIGH Migrate the main chat list to FlashList Dec 2, 2024
@muttmuure muttmuure changed the title HIGH Migrate the main chat list to FlashList HIGH: Migrate the main chat list to FlashList Dec 2, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 3, 2025
@garrettmknight
Copy link
Contributor

@janicduplessis @hannojg same question! any updates here?

@melvin-bot melvin-bot bot removed the Overdue label Jan 6, 2025
@hannojg
Copy link
Contributor

hannojg commented Jan 7, 2025

Current status update to using FlashList

We are still in the process of trying to fix maintainVisibleScrollPosition for FlashList.

FlashList is based on recyclerlistview which was not designed in a way that makes it easy to maintain scroll position.
Our current work is split between these branches:

To summarise:

  • We are still working on adding the features to FlashList needed / fixing bugs to make it work well for expensify.
  • When we have all those changes ready we'd need to make a big patch for expensify + open upstream PRs
    • Given how slow the bi-directional support PR is coming along in FlashList its questionable how fast our changes will go upstream.
    • It might makes more sense to add the packages as custom modules to expensify and maintain from the code on our own (to be discussed)

Something else we'd like to discuss is trying out a new list library called legend-list. It supports maintainVisibleScrollPosition inherently, is JS only but said to be much better performing than FlatList.
It might be that his library as a "faster FlatList" alternative that already includes the features we need is a better bet than going down the road with our "custom FlashList fork". I will open a separate ticket for investigating this if you agree?

@mountiny
Copy link
Contributor

mountiny commented Jan 7, 2025

I will open a separate ticket for investigating this if you agree?

I think this is tricky as I bet there is many alternatives to explore. I think we should aim to look at the most popular and supported options.

Feel free to check it out and if its really promising, consider doing some MVP and posting a proposal, but lets try not to spend too much time on it

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
Status: HIGH
Development

No branches or pull requests

7 participants