Repository navigation
Keep the live script off the clock unless its episode is playing - #92
Merged
Merged
Conversation
LiveScript read currentTime in render, so every episode stage re-rendered on each timeupdate, playing or not, and rebuilt its speaker set from every cue each time. The live line now comes from a computed signal that returns -1 before reading the clock when the episode isn't current, so other stages never subscribe and the playing one re-renders only when its line moves. FullPlayButton reads whether it is current through a computed, as PlayToggle does, and Scrubber looks up the dock once instead of per tick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
We want to merge
media-redesigninto main with confidence, and review flagged a render hot path first.LiveScriptreadcurrentTime.valueduring render, so every episode stage subscribed to the playback clock. Open episode B's page while episode A plays, and B's stage re-rendered about four times a second for nothing. Each of those renders also rebuilt aSetover every cue to count speakers.What changed
LiveScript.tsx: the cues live in a signal, and the live line comes fromuseComputed. It returns -1 before readingcurrentTimewhen this episode isn't current, so non-current stages never subscribe to the clock. The playing stage re-renders only when the live index changes, not every quarter second. The +0.25 s lookahead and the idle preview are unchanged.speakersis memoised on the cues.FullPlayButton.tsx:isCurrentis read throughuseComputed, asPlayTogglealready does, so switching episodes re-renders only the buttons whose state flips.Scrubber.tsx: the preview's portal target (.dock) is looked up once at mount instead of on every timeupdate render. The Island sits inside the persisted.dock, so the node is stable.tests/unit/LiveScript.test.tsx: the live line follows the clock for the playing episode, a stage for another episode stays on its preview as the clock moves, and a render count. The render count is the perf contract this PR exists for: sweeping the clock 0 to 10 s in quarter seconds with one current and one non-current stage gives 1 render (the line change at 9.75 s). The old code gives 78 on the same test.Verification
LiveScriptrenders over 10 s of playback with a temporary counter (removed before commit). Before: 38, 37, 37. After: 0, 0, 0. Media advanced 10 s in every run. CDPScriptDurationover the window was 6.6 to 6.9 ms before and 7.3 to 11 ms after, which is within noise: those renders produced an unchanged tree, so their cost was small. The win is the removed subscription and render work, not a visible scripting drop.pnpm test:unit: 31 files, 276 tests passed.pnpm exec playwright test tests/e2e/episode.spec.ts tests/e2e/player.spec.ts --project=chromiumagainst :4334: 37 passed. A first run with default workers had 3 player tests time out waiting for remote media to advance. The same 3 passed alone on both the base and this branch, and the full 37 passed with--workers=4.pnpm lint: clean.pnpm build: exit 0,astro check0 errors.🤖 Generated with Claude Code