Skip to content

fix: stop native audio sources during playback cleanup - #239

Merged
ctoth merged 2 commits into
masterfrom
fix/playback-cleanup-stop
Sep 24, 2026
Merged

ctoth merged 2 commits into
masterfrom
fix/playback-cleanup-stop

Conversation

@ctoth

@ctoth ctoth commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Sound.cleanup() disconnected buffer sources without stopping them, so native loops kept running and retaining decoded audio. Stop started sources during terminal Playback.cleanup(), after detaching the end callback. Preserve shared Sound buffers, sibling voices, and stopped-playback replay.

Unit and native browser regressions failed before the fix and passed afterward. The browser fixture renders offline and reconnects the silent source after cleanup, proving that termination survives reconnection without depending on an audio device. The final fixture also failed against unchanged master and passed against the fix on Linux WebKit.

A controlled Chromium probe with 40 six-second stereo buffers retained 40 native sources and 92.16 MB of PCM before the fix; after the fix, no sources survived cleanup and that storage was released without closing the context.

Validation:

  • npm run build
  • npx vitest run
  • npx biome ci .
  • npx playwright test browser-tests/cleanup.spec.ts --project chromium
  • npx playwright test browser-tests/cleanup.spec.ts --project firefox --project webkit (Firefox passed; Windows WebKit lacks AudioContext and skipped)

@ctoth
ctoth merged commit dd59bd8 into master Sep 24, 2026
9 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.

1 participant