perf(backgrounds): animated chat backgrounds cost ~5% CPU instead of 50 to 70% (#337) #361

Merged
jared merged 2 commits from fix/animated-bg-compositor into lotus 2026-10-16 20:52:35 -04:00
Owner

Fixes #337.

background-position can't run on the compositor, so every frame of the animated chat backgrounds repainted the whole chat area. That cost 51 to 72% main-thread busy while sitting idle in a room at 60 fps.

The drifts are slow: 3 to 22 px/s, under a pixel per frame. So each animation now uses steps(): about 12 updates/s for fireflies, stars and aurora, and about 24/s for the faster rain and pulse.

Measured headless (20 s idle in a room, CDP TaskDuration):

background before after
none 0.7% 0.9%
rain 50.7% 5.9%
stars 71.2% 4.5%
pulse 64.9% 5.8%
aurora 58.9% 4.2%
fireflies 71.7% 3.8%

Visual note: aurora and pulse used ease-in-out. With steps(), their motion is now even-paced. The layers and colours are unchanged, and Pause animations / reduced motion still remove the animation entirely.

tsc clean · unit tests pass · ESLint/Prettier clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5

Fixes #337. `background-position` can't run on the compositor, so every frame of the animated chat backgrounds repainted the whole chat area. That cost **51 to 72% main-thread busy** while sitting idle in a room at 60 fps. The drifts are slow: 3 to 22 px/s, under a pixel per frame. So each animation now uses `steps()`: about **12 updates/s** for fireflies, stars and aurora, and about **24/s** for the faster rain and pulse. **Measured** headless (20 s idle in a room, CDP `TaskDuration`): | background | before | after | |---|---|---| | none | 0.7% | 0.9% | | rain | 50.7% | **5.9%** | | stars | 71.2% | **4.5%** | | pulse | 64.9% | **5.8%** | | aurora | 58.9% | **4.2%** | | fireflies | 71.7% | **3.8%** | **Visual note:** aurora and pulse used `ease-in-out`. With `steps()`, their motion is now even-paced. The layers and colours are unchanged, and *Pause animations* / reduced motion still remove the animation entirely. `tsc` clean · unit tests pass · ESLint/Prettier clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
jared added 1 commit 2026-10-16 19:05:56 -04:00
perf(backgrounds): animated chat backgrounds cost ~5% CPU instead of 50 to 70% (#337)
CI / Build & Quality Checks (pull_request) Successful in 1m57s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 9s
CI / Playwright smoke (e2e) (pull_request) Failing after 9m56s
2700aad209
background-position can't run on the compositor, so every frame of the
animated chat backgrounds repainted the whole chat area: 51 to 72% main-thread
busy while idle in a room at 60 fps. The drifts are slow (3 to 22 px/s,
under a pixel per frame), so each animation now uses steps(): about 12
updates/s for fireflies, stars and aurora and about 24/s for rain and
pulse.

Measured headless (20 s idle in a room, CDP TaskDuration):
  none 0.7% → 0.9%; rain 50.7 → 5.9; stars 71.2 → 4.5;
  pulse 64.9 → 5.8; aurora 58.9 → 4.2; fireflies 71.7 → 3.8.

Aurora and pulse used ease-in-out; with steps() their motion is now
even-paced. Pause animations / reduced motion still strip the animation.

Fixes #337

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
jared added 1 commit 2026-10-16 19:59:33 -04:00
Merge branch 'lotus' into fix/animated-bg-compositor
CI / Build & Quality Checks (pull_request) Successful in 1m52s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 9s
CI / Playwright smoke (e2e) (pull_request) Successful in 11m11s
d55a8ba8a5
jared merged commit 47c1e435b7 into lotus 2026-10-16 20:52:35 -04:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#361