Skip to content

Fix the timeline loading a room's entire history on open - #1373

Merged
7w1 merged 5 commits into
devfrom
fix/timeline-runaway-pagination
Jul 26, 2026
Merged

Fix the timeline loading a room's entire history on open#1373
7w1 merged 5 commits into
devfrom
fix/timeline-runaway-pagination

Conversation

@eleboucher

@eleboucher eleboucher commented Jul 26, 2026

Copy link
Copy Markdown
Member

Description

Opening a room paginated until it ran out of history, scrolling the view up as it went. Worst rooms burned 8-10s of CPU per open on a Pixel 3a.

The viewport-fill effect compared processedEvents.length against a value captured in the same render, so the guard was always true and the condition reduced to !hasRealScrollRoom || atTop. It re-runs on every length change, so staying near the top kept it firing. Pre-existing since March, triggered by #1363 leaving fewer rendered events per page.

Also in here:

  • setAtBottom was only called from the scroll handler, so a resize (composer, keyboard) left it stale and killed auto-follow. Now recomputed from the ResizeObserver.
  • Notification sound gates on window focus instead of tab visibility. A visible but unfocused window is now silent unless background notification sounds is on.
  • Desktop reads window focus from onFocusChanged, since focusin/focusout miss app switches. Mobile and web unchanged.

Pixel 3a, release builds, CPU per room open:

before after
Sable Announcements 9.72s 1.06s
1 (DM) 8.03s 2.57s
10 DMs 31.34s 17.19s

Fixes #1371

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

@eleboucher
eleboucher marked this pull request as ready for review July 26, 2026 12:15
@eleboucher
eleboucher requested review from 7w1 and hazre as code owners July 26, 2026 12:15
@eleboucher eleboucher changed the title Fix/timeline runaway pagination Fix the timeline loading a room's entire history on open Jul 26, 2026
@eleboucher
eleboucher marked this pull request as draft July 26, 2026 14:14
@eleboucher
eleboucher force-pushed the fix/timeline-runaway-pagination branch from b9f33db to 72b0580 Compare July 26, 2026 14:47
@eleboucher
eleboucher marked this pull request as ready for review July 26, 2026 15:42
@eleboucher

Copy link
Copy Markdown
Member Author

play wright is flaky because of c10y

@eleboucher
eleboucher force-pushed the fix/timeline-runaway-pagination branch from 72b0580 to 33c3095 Compare July 26, 2026 15:55
@github-actions

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-1373-sable.raspy-dream-bb1d.workers.dev 33c3095 pr-1373 Sun, 26 Jul 2026 15:56:58 GMT

@7w1
7w1 added this pull request to the merge queue Jul 26, 2026
Merged via the queue into dev with commit f5650a3 Jul 26, 2026
12 of 13 checks passed
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.

Opening DMs causes timeline to keep scrolling up

2 participants