diff --git a/CHANGELOG.md b/CHANGELOG.md index e201eb4..f457897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to the Stems Toggle plugin are documented here. ## [Unreleased] +- Fix stems takeover pause-state handling and add debug logging for load-generation and playback transitions. + ## [0.9.0] — Per-stem display metadata (name/description) ### Added diff --git a/plugin.json b/plugin.json index b1ea253..5da60ae 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "id": "stems", "name": "Stems Toggle", - "version": "0.9.0", + "version": "0.9.1", "private": false, "standards": ["capability-pipelines.v1", "plugin-runtime-idempotent.v1"], "settings": { diff --git a/src/main.js b/src/main.js index cf8935f..3356ed0 100644 --- a/src/main.js +++ b/src/main.js @@ -209,6 +209,10 @@ import { // ── Teardown ── function teardown() { + // Defensive reset: a new song load starting mid-takeover (or after a + // crash before the flag was cleared) must not leave togglePlay() + // permanently ignoring real pause failures. See #39. + window._stemsRerouteInProgress = false; cleanupPointerHandlers(); if (S.pollHandle !== null) { clearInterval(S.pollHandle); @@ -770,7 +774,11 @@ import { // ── Main entry: called after song_info arrives ── async function onSongReady() { + console.log('[stems debug] onSongReady called, gen was:', S.loadGeneration); teardown(); + const gen = S.loadGeneration; + const abortController = new AbortController(); + S.abortController = abortController; const info = currentSongInfo(); const stems = (info && info.stems) || []; // Archive or stem-less sloppak — no graph to build, but keep the event @@ -784,6 +792,7 @@ import { // Done before buildGraphFromBuffers so the graph is built for the right // path. Falls back to legacy (pitch-coupling) playback otherwise. S.useWorklet = await ensureWorklet(); + if (gen !== S.loadGeneration) return; if (!S.useWorklet && !S.workletWarned) { S.workletWarned = true; console.warn('[stems] AudioWorklet unavailable — speed control will change pitch (legacy mode)'); @@ -794,10 +803,12 @@ import { // refuse the takeover and let core's native