Repository navigation
Fix stems takeover pause state handling - #2
Conversation
Reset and manage `_stemsRerouteInProgress` during song teardown and stems takeover so intentional HTML5-to-stems pauses do not get treated as real playback failures. This also adds debug logging around song readiness, shim availability, decode completion, and transport startup to help diagnose takeover races and issue got-feedBack#39.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds ChangesStems reroute lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant onSongReady
participant CoreAudio as core audio element
participant StreamingSetup as streaming setup
participant Decode as decode
participant Graph as graph construction
onSongReady->>CoreAudio: pause for stems takeover
onSongReady->>StreamingSetup: initialize with load abort signal
StreamingSetup->>Decode: process decode result
Decode->>Graph: build stems graph
Graph->>CoreAudio: start deferred playback or complete takeover
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 21 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (21 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main.js`:
- Around line 212-215: Update onSongReady() to capture the current load
generation and create its per-call AbortController immediately after teardown(),
before any await. Guard S.sloppakActive updates, _stemsRerouteInProgress
assignment, and nativeCorePause(core) with a generation check; use the local
controller for all subsequent fetch and decode operations, and ensure stale
invocations exit without affecting the newer song.
- Around line 821-830: In the existing playback check around
nativeCorePaused(core), move both the _stemsRerouteInProgress assignment and
nativeCorePause(core) call inside the branch that confirms the core is currently
playing. Leave the existing check intact so paused cores neither set the reroute
flag nor invoke the no-op pause.
- Line 925: Update the results === null branch in the playback takeover flow to
invoke the same teardown and native playback fallback used by the graph-build
failure path before hiding the overlay and clearing _stemsRerouteInProgress.
Ensure S.sloppakActive is reset and the paused core element resumes native
playback when loadStems() fails.
- Line 904: Update the reroute flow around setupStreaming() and the graph path
so window._stemsRerouteInProgress remains true until transport.playing becomes
true; remove the immediate clear before transportPlay(), and clear the flag only
when playback starts or when takeover fails or is abandoned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1c94d3ac-9900-4b64-aed5-891231d6ef34
📒 Files selected for processing (1)
src/main.js
Added per-load generation/controller guards and local abort signal usage. Prevented paused cores from triggering takeover pause logic. Added teardown/native playback fallback when loadStems() fails. Kept reroute state active until transport playback begins. Added the requested Unreleased changelog bullet.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main.js (1)
891-895: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the current playback intent before fallback playback.
wantedPlaybecomes stale during asynchronous loading. A user pause setsS.pendingPlay = false, but all fallback paths still use the earlier value afterteardown(). ReadS.pendingPlaybefore teardown, then resume#audioonly when the current intent istrue.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main.js` around lines 891 - 895, Update the fallback playback logic around teardown and the `wantedPlay` check to read the current intent from `S.pendingPlay` before calling `teardown()`. Use that captured value after teardown, and resume `#audio` only when it is true instead of relying on the stale `wantedPlay` value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main.js`:
- Around line 891-895: Update the fallback playback logic around teardown and
the `wantedPlay` check to read the current intent from `S.pendingPlay` before
calling `teardown()`. Use that captured value after teardown, and resume
`#audio` only when it is true instead of relying on the stale `wantedPlay`
value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e5f5fe86-42a8-4528-b4eb-6c279983a6f9
📒 Files selected for processing (4)
CHANGELOG.mdsrc/main.jssrc/streaming.jssrc/transport.js
Use `S.pendingPlay` instead of the stale local playback flag when stem rerouting fails or decode returns null. This keeps the core audio player resuming only when playback is still pending at fallback time, avoiding incorrect pause/resume behavior during degraded recovery.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main.js (1)
924-937: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winUse current pending-play state for graph-build fallback.
The
results === nullbranch now snapshotsS.pendingPlaycorrectly. However, the laterbuildGraphFromBuffers()failure still useswantedPlaycaptured at Line 871, before asynchronous decoding.If the user changes play intent during decoding, the fallback can resume after a pause or fail to resume after a new play request. Capture
S.pendingPlayimmediately beforebuildGraphFromBuffers()because that function callsteardown()and clears the pending state.Proposed fix
- const wantedPlay = S.pendingPlay; ... + const shouldResume = S.pendingPlay; if (!buildGraphFromBuffers(results, fullBuf)) { ... - if (wantedPlay) { + if (shouldResume) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main.js` around lines 924 - 937, Update the buildGraphFromBuffers failure path to snapshot the current S.pendingPlay immediately before calling buildGraphFromBuffers, then use that snapshot for fallback resume behavior instead of the stale wantedPlay value captured earlier. Preserve the existing teardown and overlay cleanup flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main.js`:
- Around line 924-937: Update the buildGraphFromBuffers failure path to snapshot
the current S.pendingPlay immediately before calling buildGraphFromBuffers, then
use that snapshot for fallback resume behavior instead of the stale wantedPlay
value captured earlier. Preserve the existing teardown and overlay cleanup flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b1cf8152-8431-4f9f-abaf-95fc6274e0c3
📒 Files selected for processing (1)
src/main.js
Use `S.pendingPlay` to decide whether playback should resume when graph rebuilding fails, instead of relying on `wantedPlay`. This preserves the user’s actual pending play intent and avoids leaving the player paused after a failed reroute fallback.
✅ Action performedReview finished.
|
Docstrings generation was requested by @carochacs. * #2 (comment) The following files were modified: * `src/main.js` * `src/streaming.js` * `src/transport.js`
Reset and manage
_stemsRerouteInProgressduring song teardown and stems takeover so intentional HTML5-to-stems pauses do not get treated as real playback failures. This also adds debug logging around song readiness, shim availability, decode completion, and transport startup to help diagnose takeover races and issue got-feedBack#39.