mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
## Summary Scrolling the mobile channel list hitched repeatedly after the app had been closed for a long time. To decide which rows are bold and which get a dot, the channel list read every unread message held in memory, for every channel, on every rebuild. After a long absence the unread catch-up holds up to 1000 messages per channel, so each list update cost more than a frame. This change makes a list rebuild independent of the backlog size: - A channel's messages stop being read once its bold and dot state is decided. - Each channel's result is reused until its messages or the read state change. A new message re-reads only its own channel; reordering or filtering the list re-reads nothing. Which rows end up bold or dotted is unchanged. ### Related issue N/A. None found. ### Testing Before (left) and after (right), same script on an iPhone 17 simulator: 200 channels each holding 1000 unread messages, a list update every 150 ms, and a scripted finger (the crosshair) dragging at a steady 420 px per second. https://github.com/user-attachments/assets/07b39b61-406f-4b4b-baca-69aa5be42db7 | | Before | After | |---|---|---| | Frames drawn in the 11-second drag | 279 | 499 | | Frames over 25 ms | 127 (46%) | 92 (18%) | | Median frame | 21.1 ms | 17.2 ms | | Worst frame | 116.8 ms | 65.2 ms | The recording uses scripted data in a debug build, which drops some frames even with no list updates, so the "after" side is not perfectly smooth. Whole frame after one list update, 200 channels, in a widget test on a Mac (not a phone): | Unread messages held per channel | Before | After | |---|---|---| | 0 | 13.3 ms | 12.7 ms | | 300 | 16.5 ms | 6.8 ms | | 1000 | 37.4 ms | 6.6 ms | - New tests in `channel_unread_test.dart` compare the new pass with a copy of the old full scan across a table of cases and 600 random steps of adds, deletions and read marks, and count messages read to guard the early exit and the reuse without timing. - `flutter analyze` and the mobile channel and home tests (2,983) passed with these two commits on `8827f986e43`. They were not rerun after the rebase onto current `main`, so CI is the check for that. - Not run on a phone or against a real community. Worth a close look in review: the reuse depends on every place that changes the stored unread messages marking that channel as changed. The new tests drive this through a stand-in, so they do not prove each real call site does it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: mtoohey <mtoohey@squareup.com> Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>