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

Discard any changes before we delete the persistent state

Open laevandus opened this issue 9 months ago โ€ข 3 comments

๐ŸŽฏ Goal

Make sure that changed managed object contexts do not trigger adding new data in removeAllData

๐Ÿ“ Summary

In the state layer branch we have a case where channel was not properly deleted on logout. That branch also has additional managed object context which is aggressively merging changes from other contexts (this seems to be related).

  1. Log in with A
  2. Open channel with A and B
  3. Logout and log in with B
  4. Open channel with A and B โ†’ issue happens (assert telling multiple ChannelDTOs for the same cid)

๐Ÿ›  Implementation

Reset contexts when we logout for making sure we discard any active changes and do not try to save them when later the code path calls writableContext.save.

๐ŸŽจ Showcase

From: feature/chat-state-layer 325224767-97655b0b-25bb-4976-9270-dabc040fe7e2

๐Ÿงช Manual Testing Notes

Follow the steps above.

โ˜‘๏ธ Contributor Checklist

  • [x] I have signed the Stream CLA (required)
  • [x] This change follows zero โš ๏ธ policy (required)
  • [x] This change should be manually QAed
  • [x] Changelog is updated with client-facing changes
  • [ ] New code is covered by unit tests
  • [ ] Comparison screenshots added for visual changes
  • [ ] Affected documentation updated (docusaurus, tutorial, CMS)

laevandus avatar Apr 29 '24 06:04 laevandus

StreamChat XCMetrics

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 3.34 ms 66.6% ๐Ÿ”ผ ๐ŸŸข
Duration 2.6 s 2.55 s 1.92% ๐Ÿ”ผ ๐ŸŸข
Hitch time ratio 4 ms per s 1.31 ms per s 67.25% ๐Ÿ”ผ ๐ŸŸข
Frame rate 79 fps 78.66 fps 0.43% ๐Ÿ”ผ ๐ŸŸข
Number of hitches 1 0.4 60.0% ๐Ÿ”ผ ๐ŸŸข
ChannelList Hitches total duration 12.5 ms 0.0 ms 100.0% ๐Ÿ”ผ ๐ŸŸข
Duration 2.6 s 0.83 s 68.08% ๐Ÿ”ผ ๐ŸŸข
Hitch time ratio 5 ms per s 0.0 ms per s 100.0% ๐Ÿ”ผ ๐ŸŸข
Frame rate 76 fps 62.81 fps 17.36% ๐Ÿ”ผ ๐ŸŸข
Number of hitches 1.2 0.0 100.0% ๐Ÿ”ผ ๐ŸŸข

Stream-SDK-Bot avatar Apr 29 '24 06:04 Stream-SDK-Bot

I will hold this one until we have released 4.53.0.

laevandus avatar Apr 30 '24 06:04 laevandus