mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 07:42:24 -08:00
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### 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 - [x] 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: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] 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). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->