perf: prevent recycling remounting in MessageContent descendants#3696
Merged
Conversation
Contributor
SDK Size
|
szuperaz
approved these changes
Jul 2, 2026
6 tasks
isekovanic
added a commit
that referenced
this pull request
Jul 2, 2026
## π― Goal This PR is a followup to [this change](#3696). In addition to making sure React doesn't remount components while recycling, we also have to make sure to try resolving components in the recycling pool as fast as possible. For instance, if all messages with attachments belong to the same pool we can get into a situation where we try to recycle something like a voice recording into a gallery. This, needless to say is going to be super suboptiomal. Possibly worse than having no item type at all (since voice recording as an example has so many subcomponents it would take some serious effort to clean them up from the GC side as well as all of the Fabric nodes). With this change we try to improve that by making the recycling pool (especially for attachments) way more explicit. ## π Implementation details <!-- Provide a description of the implementation --> ## π¨ UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## π§ͺ Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## βοΈ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π― Goal
This PR fixes a relatively critical performance issue with our
MessageFlashList, where due to how our component structure works basically any downstream leaf ofMessageContentwas being hard remounted. Passing non-recycling stable keys essentially kills the entire point of recycling and defeats our main mechanism to gain performance here.There are still some more (perhaps not so obvious places) where this can be improved, however we want to take this one step at a time and do it carefully since these changes are quite finicky.
Another PR will follow with performance improvements to the way we fetch the item type (also responsible for some remounts).
Later on we can also explore using the
useMappingHelperhook from the library itself and seeing if that'll improve even further. But, one step at a time.π Implementation details
π¨ UI Changes
iOS
Android
π§ͺ Testing
βοΈ Checklist
developbranch