Skip to content

Perf: confine 20 Hz playback invalidation to leaf views; trim per-render waste - #119

Merged
sanylax0 merged 1 commit into
mainfrom
claude/repo-review-improvements-yvk3t7-ui-perf
Jul 20, 2026
Merged

sanylax0 merged 1 commit into
mainfrom
claude/repo-review-improvements-yvk3t7-ui-perf

Conversation

@sanylax2

Copy link
Copy Markdown
Collaborator

Part 4 of the CPU/memory audit — SwiftUI render churn. Pixel-identical UI, strictly less recomputation.

  • The big one: the Now Playing sheet's transition section read transitionProgress and secondsUntilTransition — both derived from the 20 Hz position writes — inline in the sheet body. Result: the entire sheet (artwork tile, labels, scrubber, transport, chips) re-evaluated 20×/s whenever it was open during playback, and throughout every blend. Extracted verbatim into a TransitionSection leaf view, same subtree and .transition(.opacity), so only the leaf re-evaluates — the same isolation pattern already used for the progress ring / scrubber / mini-player line.
  • TransitionVisualizationView recomputed TransitionPreview.make(...) on every property access (3×+ per frame during live blends); it's a pure function of the init inputs and is now computed once at construction.
  • SearchView dropped its @Query — which hydrated every Track (beat grids included) and held a live subscription re-firing on any library change while search was open — for a one-shot fetch of just title/artist.
  • The custom keyboard's suggestion bar is now a leaf view: keystrokes stop rebuilding the ~40-button key grid.
  • UpNextView captures upcomingTracks once per body (fresh array allocation per access, previously read twice).

Device check

  • Now Playing sheet: countdown, live blend graph, chips all behave identically; sheet interactions stay smooth during a blend.
  • Search: suggestions, typing, results unchanged.
  • Up Next: reorder/remove unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP


Generated by Claude Code

Audit part 4 — pixel-identical UI, less recomputation:
- The Now Playing sheet's transition section read transitionProgress and
  secondsUntilTransition (both derived from the 20 Hz position writes)
  inline, re-evaluating the ENTIRE sheet 20x/s whenever it was open.
  Extracted into a TransitionSection leaf view — same subtree, same
  transitions — so only the leaf re-evaluates.
- TransitionVisualizationView computed TransitionPreview.make on every
  access (3x+ per frame during live blends); now computed once at init.
- SearchView dropped its @query (which hydrated every Track including
  beatTimes and kept a live subscription while search was open) for a
  one-shot title/artist-only fetch.
- The custom keyboard's suggestion bar is a leaf view, so keystrokes
  stop rebuilding the ~40-button key grid.
- UpNextView captures upcomingTracks once per body (it allocates a fresh
  slice per access and was read twice).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP
@sanylax0
sanylax0 merged commit 47c3865 into main Jul 20, 2026
4 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.

3 participants