stream-chat-swift icon indicating copy to clipboard operation
stream-chat-swift copied to clipboard

[CIS-2084, CIS-2085] New Message List Diffing Implementation

Open nuno-vieira opened this issue 2 years ago • 3 comments

🔗 Issue Links

CIS-2084 CIS-2085 https://github.com/GetStream/stream-chat-swift/issues/2094

Bonus: https://github.com/GetStream/stream-chat-swift/issues/2184

🎯 Goal

The goal of this PR is to fix the crashes in the message list related to data inconsistencies in performBatchUpdates and also to fix the message list jumps when receiving multiple messages and the user is scrolled up.

📝 Summary

  • Adds DifferenceKit dependency to StreamChatUI.
  • Removes the_messageListDiffingEnabled flag, since now we only have 1 implementation of the message list and it is not experimental anymore
  • Instead of relying on ListChange updates from StreamChat, now the StreamChatUI applies changes from the diffing calculation of the old messages snapshot, and the newest message snapshot
  • Skips bottom insertions at the bottom when the user is scrolled up. With the diffing logic in place, now it is easier to skip bottom insertion updates when the user is scrolled up. This avoids the message list jumps because the insertions at the bottom don't actually happen until the user scrolls to the bottom again. This not only avoids the message list jumps but also makes the message list more performant and efficient.
  • Improves the performance of the message list when multiple messages are being inserted at the same time and there are already a lot of messages loaded. (Most of this improvement was by skipping channel list updates while the channel list is not visible. After profiling the application, the main thread was mostly blocked by the channel list updates, and the root cause is being fixed here: https://github.com/GetStream/stream-chat-swift/pull/2168. Either way, it doesn't make sense for the channel list to impact the message list while the user is on the message list. The https://github.com/GetStream/stream-chat-swift/pull/2168 PR will also improve even further the message list performance especially when it is being overloaded. Right now the DTO mappings on the main thread are the only optimisation left in the Message List. Even though we have right now a good 56/60FPS average when the message list is being overloaded.

Missing Tasks:

  • [ ] Skipping logic test coverage
  • [x] Properly add the DifferenceKit dependency using the bash script

🎨 Showcase

Loading Previous Messages No jumps

🧪 Manual Testing Notes

  • [ ] Mob Regression Testing

☑️ Contributor Checklist

  • [x] I have signed the Stream CLA (required)
  • [x] Changelog is updated with client-facing changes
  • [ ] New code is covered by unit tests
  • [x] This change follows zero ⚠️ policy (required)
  • [x] Comparison screenshots added for visual changes
  • [x] Affected documentation updated (docusaurus, tutorial, CMS)

🎁 Meme

nuno-vieira avatar Aug 09 '22 14:08 nuno-vieira

📏 Size Analysis

Total install size 9.6 MB | This change: ⬆️ +45.7 kB (+0.476%)

Image of diff

🗂 See size breakdown
Item Install size
➖ StreamChat.framework/Strings.CFStrings ⬇️ 46.5 kB
➕ ChatSample/Strings.CFStrings ⬆️ 46.4 kB
ChatSample/External Methods ⬆️ 39.7 kB
StreamChat.framework/DYLD.String Table ⬇️ 29.7 kB
StreamChat.framework/Strings.Unmapped ⬇️ 22.3 kB
➖ StreamChat.framework/SentryCrashReportConverter ⬇️ 21.9 kB
StreamChat.framework/Code Signature ⬇️ 21.2 kB
ChatSample/Strings.Unmapped ⬆️ 21.1 kB
➖ StreamChat.framework/SentryOptions ⬇️ 20.7 kB
➕ StreamChatUI.framework/StreamChatUI.ChatMessage.isContentEqual(to) ⬆️ 20.4 kB
ChatSample/Code Signature ⬆️ 20.2 kB
➖ StreamChat.framework/SentryTracer ⬇️ 17.4 kB
➖ StreamChat.framework/SentryClient ⬇️ 17.3 kB
StreamChat.framework/DYLD.Exports ⬇️ 16.3 kB
StreamChat.framework/External Methods ⬇️ 16.2 kB
➖ StreamChat.framework/SentryScope ⬇️ 16.2 kB
➖ StreamChat.framework/SentryFileManager ⬇️ 15.9 kB
ChatSample/DYLD.Exports ⬆️ 14.7 kB
➖ StreamChat.framework/SentryHub ⬇️ 12.8 kB
➖ StreamChat.framework/SentryCrash ⬇️ 12.6 kB

🔎 See the full size analysis (c5b16c5) merging into develop (86daace)

Provide a baseSha and pullRequestNumber with your upload to ensure diffs are correct. Read more in the docs

emerge-tools[bot] avatar Aug 09 '22 15:08 emerge-tools[bot]

1 Warning
:warning: Big PR

Generated by :no_entry_sign: Danger

Stream-SDK-Bot avatar Aug 09 '22 17:08 Stream-SDK-Bot