mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2750] [Issue]: Game-mode music overlap — stopMusic fade-out interval untracked, old + new music stack on scene change (+ crossfade glitches/leak) #1391
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1391
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2750
Originally assigned to: @SpicyMarinara on GitHub.
Summary
game-audio.tshas several audio-lifecycle defects centered on the music/ambient crossfade machinery. The flagship is thatstopMusic()'s fade-out interval is never stored inthis.fadeInterval, so it cannot be cancelled — anddispose()(called on scene-scope change and unmount) starts that uncancellable 2s fade while the next scene'splayMusic()crossfades a new track in on top, producing audible overlap (the same class as prior bug #2647).Sub-bug 1: Untracked fade-out -> overlap (#10/#46) [primary]
this.fadeInterval(the crossfade-in), nullsthis.musicElement, then starts a localconst interval = setInterval(...)(764-771) that is NEVER assigned tothis.fadeInterval. playMusic's guardif (this.fadeInterval) clearInterval(662) finds nothing to cancel, so the old fade-out and the new crossfade-in run concurrently for ~2s. dispose() therefore never hard-stops music.interval-> next scene playMusic() 662this.fadeIntervalis null -> 690 new crossfade-in runs alongside the 764 fade-out.Sub-bug 2: Fallback silenced by suspended context (#11)
<audio>, then applyVolume -> setElementLayerVolume -> getMediaGain callsctx.createMediaElementSource(fallbackAudio)(283), re-attaching the element to the same suspended context. Once captured, the element's only output is the (silent) Web Audio graph.audio.volumedirectly and never captures the element.)Sub-bug 3: Volume slider during crossfade pops (#47)
this.nextMusicElement?.setVolume(this.musicVolume)andthis.musicElement?.setVolume(...). During a crossfadenextMusicElementis the fading-in track andmusicElementthe fading-out track; both are slammed to full viagain.setValueAtTime(immediate), then the next ≤50ms fade tick (690-706) yanks them back to the partial value. Cosmetic volume pop/stutter, self-heals in one tick.Sub-bug 4: Ambient overlap on rapid changes (#49)
this.ambientElement(nonextAmbientElement); the pending next-ambient is a local var. Two playAmbient calls within one fetch/decode window both start their BufferSource on decode; the stale one is stopped only a tick later by its ready guard, producing a brief double-ambient blip with no synchronous cancel handle.Suggested Fix
this.fadeInterval(and stop the capturedaudioon a second stop/dispose). Give dispose() animmediatehard-cut path that callsaudio.stop()right away instead of fading into the next scene.fallbackAudio.volumedirectly and skipgetMediaGain/createMediaElementSource(or gate getMediaGain onctx.state === 'running').this.musicVolumeand let the fade interpolate toward it; don't directly set the in-fade elements.this.nextAmbientElementmirroringnextMusicElement; stop any pending next-ambient on entry and in stopAmbient().Verification checklist (all manual)
pnpm checkAffected files
packages/client/src/lib/game-audio.tspackages/client/src/components/game/GameSurface.tsxAudit provenance
Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged
stagingtree. Severity: HIGH.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed on PR #2747. game-audio now tracks and cancels fade-out music via fadingMusicElement/fadeInterval, dispose hard-cuts music, fallback media elements no longer get routed through a suspended Web Audio context, volume changes no longer slam both music layers during active crossfade, and ambient playback has a tracked pending layer that stop/mute/volume/dispose can cancel. Deferred full pnpm validation until the end of the issue sweep per maintainer request.