Repository navigation
fix(editor): unmount inactive layout — kill duplicate <MasterAudio>/<TransportBar> - #18
Merged
Merged
Conversation
…udio>/<TransportBar>
EditorShell rendered the desktop and mobile layouts side-by-side and
relied on `hidden lg:grid` / `lg:hidden` to swap them. Both branches
received the SAME `videoArea`/`transport`/`timeline` ReactNodes, so
React mounted each twice — including <MasterAudio> (= a second WebAudio
ping-pong wired into ctx.destination) and <TransportBar> (= a second
window keydown listener). Two effects:
- Loop "phasing" across the whole region: two parallel ping-pong
setups decoded the same source with independent decoder latencies
and summed into the same destination, producing constant comb-
filtering through every loop iteration. Verified via React fiber
walk: 2× MasterAudio + 4 <audio> elements before, 1× and 2 after.
- Arrow-key snap navigation stepped 2× the snap distance: each
keypress fired both TransportBars' onKey, dispatching
stepByActiveSnap twice. Verified live: 0.43s → 2.43 → 4.43 → 6.43
after the fix (was 0.43 → 4.43 → 8.43 → 12.43 before).
Fix: gate each layout branch on `useIsLargeViewport()` so only the
matching one mounts. Also tighten stepByActiveSnap's eps fallback from
`step * 0.01` (= 20ms at 1-bar / 120bpm, wide enough to falsely fire
when the playhead lands within 1% of a snap) to `step * 1e-9` (FP
tolerance only — the fallback exists solely to absorb Math.round's
round-half-toward-+∞ asymmetry on negative half-tick probes).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
10 tasks
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.
Summary
EditorShell mounted both desktop and mobile layouts simultaneously and used CSS (
hidden lg:grid/lg:hidden) to swap them. Both branches received the samevideoArea/transport/timelineReactNodes — React mounted each twice. Two visible bugs from one root cause:<MasterAudio>= two parallel WebAudio ping-pong setups, each decoding the same source with independent decoder latencies, both summed intoctx.destination→ constant comb-filtering through every loop iteration.<TransportBar>= twowindow.addEventListener("keydown", ...)listeners → each press firedstepByActiveSnaptwice.Verified live in browser via React fiber walk: 2× MasterAudio + 4
<audio>elements before, 1× and 2 after. Snap jump 0.43→2.43→4.43→6.43 after fix (was 0.43→4.43→8.43→12.43).Changes
EditorShell.tsx: newuseIsLargeViewport()hook; conditionally render only the matching layout branch instead of CSS-toggling both.store.ts:1044: tightenstepByActiveSnap's eps fallback fromstep * 0.01(= 20 ms at 1-bar/120bpm — wide enough to falsely fire when the playhead lands within 1% of a snap, e.g. via audio-mirror seek precision) tostep * 1e-9(FP tolerance only — the fallback exists solely to absorbMath.round's round-half-toward-+∞ asymmetry on negative half-tick probes).store.test.ts: 2 new regression tests forstepByActiveSnapnear-snap edge cases.Test plan
bun test)🤖 Generated with Claude Code