Skip to content

perf: prevent recycling remounting in MessageContent descendants#3696

Merged
isekovanic merged 1 commit into
developfrom
perf/recycling-remounts
Jul 2, 2026
Merged

perf: prevent recycling remounting in MessageContent descendants#3696
isekovanic merged 1 commit into
developfrom
perf/recycling-remounts

Conversation

@isekovanic

@isekovanic isekovanic commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🎯 Goal

This PR fixes a relatively critical performance issue with our MessageFlashList, where due to how our component structure works basically any downstream leaf of MessageContent was 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 useMappingHelper hook from the library itself and seeing if that'll improve even further. But, one step at a time.

πŸ›  Implementation details

🎨 UI Changes

iOS
Before After
Android
Before After

πŸ§ͺ Testing

β˜‘οΈ Checklist

  • I have signed the Stream CLA (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

@isekovanic isekovanic requested review from oliverlaz and szuperaz July 2, 2026 12:15
@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 1974 KB 1974 KB -43 B πŸš€

@isekovanic isekovanic merged commit 0e5a005 into develop Jul 2, 2026
11 checks passed
@isekovanic isekovanic deleted the perf/recycling-remounts branch July 2, 2026 13:38
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
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.

3 participants