regression: fix scroll performance in message list
Draft
CA
5mo ago+73+73+01234567890123456789-30-30-01234567890123456789
Proposed changes (including videos or screenshots)
This PR improves scroll performance in the room message list by reducing synchronous work in hot paths that run during rapid scrolling.
Main changes:
- Replaced synchronous restore behavior in the message loading flow with transition-based scheduling to avoid blocking the main thread during heavy updates.
- Added requestAnimationFrame scheduling around scroll-triggered checks in the message history loader so multiple scroll, mutation, and resize events are coalesced per frame.
- Reduced layout pressure in the history loader by using direct element scroll metrics in the hot path.
- Added frame-based scheduling to the date bubble scroll handler to limit expensive geometry reads during continuous scrolling.
- Added cleanup for pending animation frames, debounced work, and timeouts to prevent stale work after unmount.
- Updated the related hook tests to reflect async/frame-scheduled behavior.
Issue(s)
Steps to test or reproduce
- Open a room with enough messages to trigger virtualization behavior.
- Scroll quickly up and down for several seconds.
- Confirm older/newer messages still load correctly near list boundaries.
- Confirm scroll restoration behavior still works when loading previous messages.
- Confirm date bubble behavior is preserved while scrolling.
- Record a Performance profile in DevTools and compare against baseline:
- Lower time spent in synchronous commit/unmount activity.
- Fewer geometry-read bursts during scroll handling.
Further comments
This change is intentionally scoped to scheduling and event handling in existing hooks to minimize behavioral risk while targeting the largest observed bottlenecks.
A potential follow-up is to evaluate additional virtualizer tuning to further reduce large unmount bursts in extreme scroll scenarios.