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

Optimise channel list view updates #561

Merged
merged 9 commits into from
Jul 31, 2024
Merged

Optimise channel list view updates #561

merged 9 commits into from
Jul 31, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Jul 30, 2024

🔗 Issue Link

PBE-5004

🎯 Goal

Reduce hitches and hangs while scrolling the channel list

🛠 Implementation

  • Remove explicit view ids from channel list (causes full view reloads and not needed after ChatChannel equality implementation was changed)
  • swipedChannelId sometimes causes unnecessary view updates while just scrolling down
  • Optimise channel avatar loading by not triggering updates on the channel list level and instead observing it on the ChannelAvatarView level instead (more concise view update cycle when avatar loading finishes)

🧪 Testing

Exploratory testing on channel list updates (last message preview, sorting)

🎨 Changes

I did measurements using iPhone 12 Pro Max and repeated each measurement 3 times.
Steps:

  1. Use "Animation Hitches" template
  2. Launch the demo app and wait until it settles (account Chewbacca)
  3. Slowly scroll down in the channel list until we reach the very last channel (paginating to the oldest channel)
    Count hitches and hangs during the duration of scrolling in the channel list.

Baseline

Measurement Run 1 Run 2 Run 3
Hitches 18 22 24
Hangs 15 20 24

Remove explicit view ids

Measurement Run 1 Run 2 Run 3
Hitches 18 16 13
Hangs 18 15 11

Remove explicit view ids + swipedChannelId change

Measurement Run 1 Run 2 Run 3
Hitches 18 22 28
Hangs 16 10 12

Remove explicit view ids + swipedChannelId change + avatar optimisation

Measurement Run 1 Run 2 Run 3
Hitches 7 5 5
Hangs 3 5 3

Based on the data the avatar change is the biggest contributor, while swipedChannelId does not add much or anything but I still decided to keep that tiny change.

In average the PR reduces hitches ~3.5 times and hangs ~5 times

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created)

@laevandus laevandus requested a review from a team as a code owner July 30, 2024 10:33
@laevandus laevandus changed the title Perf/channel list Optimise channel list view updates Jul 30, 2024
@laevandus laevandus force-pushed the perf/channel-list branch from a3e158e to 7c47795 Compare July 30, 2024 10:34
Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

seems like you forgot to push the OnLoadViewModifier?

@laevandus
Copy link
Contributor Author

seems like you forgot to push the OnLoadViewModifier?

Indeed!

@laevandus laevandus force-pushed the perf/channel-list branch from f054e11 to 76c71fd Compare July 31, 2024 06:09
@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Jul 31, 2024

SDK Size

title develop branch diff status
StreamChatSwiftUI 6.96MB 7.01MB 0.05MB 🟢

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

great work, there are noticeable performance improvements 👏 I did some tests, things seem to be working well. @testableapple would be nice to also give it a go - mostly testing around the channel list. I would like to include this in the SwiftUI release today.

@laevandus
Copy link
Contributor Author

QAd with @testableapple

@laevandus laevandus enabled auto-merge (squash) July 31, 2024 11:34
Copy link

@laevandus laevandus merged commit e4a405e into develop Jul 31, 2024
11 checks passed
@laevandus laevandus deleted the perf/channel-list branch July 31, 2024 13:00
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Jul 31, 2024
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