Skip to content

Conversation

@isekovanic
Copy link
Contributor

@isekovanic isekovanic commented Oct 9, 2025

🎯 Goal

This PR implements significant (optional) performance improvements for our MessageList component in very high WS event traffic situations.

Provided below is a non-exhaustive list of everything done:

  • Fixes isLiveStreaming mode for both list implementations
  • Some QOL improvements for the experimental FlashList
  • Adds RAF coalescing to FlashList
  • Implements viewport-aware message pruning for both lists
    • A new hook is added with respect to this called usePrunableMessageList
  • Properly exhumes animated wrappers and shared values when swipeToReply is disabled
  • Implements throttling of ChannelPreview updates during high traffic

Although all of the performance improvements are significant, the heaviest hitters here are message pruning and the ability to turn swipe-to-reply off.

  1. Message pruning is particularly significant because of the memory footprint tons of messages leave. The footprint does not occur from actual messages kept in memory (i.e objects), but rather layout and frame calculations that FlatList caches if items are rendered at all even once, as well as references to native views that prevent the GC from cleaning stuff up properly (or fast enough). This way, we force the list to treat items outside of our window as "removed" - and then paginate as needed to the old items. This can be improved in the future, needless to say - this fix is just immediate measure. Pruning is not needed at all for FlashList due to how it handles things internally, nor does it work properly, so it should be avoided (MVCP sometimes breaks for certain window thresholds).
  2. The swipe-to-reply animated wrappers would create both shared values as well as Gestures as well as some other overhead regardless of whether it's been enabled or not. Normally, this is pretty insignificant - but multiplied by many, many messages it caused a constant increase in memory as messages arrive and are rendered at least once. This was especially noticeable on Android and easily debuggable through the performance module in AS. This is also something that can be done in a better way in the future, however in the interest of time right now and so that livestreaming is amendable this'll have to do for now.

Note: This PR has to be merged and stream-chat updated before we can proceed with releasing this one.

🛠 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

@Stream-SDK-Bot
Copy link
Contributor

Stream-SDK-Bot commented Oct 15, 2025

SDK Size

title develop branch diff status
js_bundle_size 290 KB 291 KB +1019 B 🔴

Copy link
Member

@khushal87 khushal87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just please not down the issues with FlashList somewhere so that we can refer.

@isekovanic isekovanic merged commit 48385b8 into develop Oct 15, 2025
4 of 6 checks passed
@isekovanic isekovanic deleted the perf/livestreaming-improvements branch October 15, 2025 11:27
@github-actions github-actions bot mentioned this pull request Oct 15, 2025
6 tasks
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.

4 participants