mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2647] [Issue]: Game-mode voice auto-play loops/duplicates the same line until stopped #1304
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#1304
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 @aeriondyseti on GitHub (Jun 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2647
Summary
In game (GM) mode with voice auto-play enabled, the narrated voice line keeps restarting/duplicating — the same line plays over and over (audibly overlapping with itself) until playback is manually stopped.
Expected behavior
Each segment/side-line voice clip auto-plays once when it becomes ready, then advances to the next. A line should never restart from the top on its own.
Actual behavior
While a scene's voice clips are still being generated, the active line restarts repeatedly and overlaps itself, continuing until the user hits stop.
Root cause (analysis)
This is specific to the game-mode voice queue in
packages/client/src/components/game/GameNarration.tsx. The roleplay/VN path uses thettsServicesingleton (packages/client/src/lib/tts-service.ts), which commits its dedup synchronously viastop()+ asequencecounter and is not affected.The "already auto-played" guards are written asynchronously but read on a synchronous churn signal, so the guard is perpetually stale:
GameNarration.tsx:2866) only sets its dedup reflastAutoPlayedVoiceKeyRefinside theonStartedcallback, which fires when the browser actually begins playback (audio.onplaying/play().then(...)) — tens of ms later.GameNarration.tsx:2890) depend ongameVoiceVersion.gameVoiceVersionis bumped every time a voice blob finishes generating (GameNarration.tsx:2782), plus on side-voice start/block/retry (2918,2929,1852).So while clips are still generating,
gameVoiceVersionincrements rapidly and re-runs the auto-play effect. If the current clip'sonStartedhasn't fired yet, the dedup ref is still stale, so the effect callsplayGameVoiceKey(activeVoiceKey)again →playGameVoiceKeys()runsstopGameVoicePlayback()and restarts the same line from the top (GameNarration.tsx:1751–1826). Generation churn faster than playback-start ⇒ continuous restart, and the stop/restart race on the<audio>element is the audible overlap. The side-voice effect has the same shape and even bumps the version itself inonStarted(2918), feeding the loop.Proposed fix
Close the async gap by marking a key as "attempt in flight" synchronously when
playGameVoiceKey/playGameVoiceKeysis invoked (a ref the auto-play effects also check), then:onStarted→ commit to the real dedup ref/Set and clear in-flight;onBlocked→ clear in-flight so the existing autoplay-blocked retry path still works (dedup was deferred toonStartedoriginally to allow retry-on-block, so a purely synchronous commit would regress that; the in-flight ref preserves it).Steps to reproduce
Environment
staging)Additional context
Discovered while investigating per-character voice playback. Affects game mode only; roleplay/VN/conversation auto-play (the
ttsServicesingleton path) is unaffected. Fix to be made againststagingperCONTRIBUTING.md.Template check
@aeriondyseti commented on GitHub (Jun 19, 2026):
Taking this for myself.
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Thank you pookie, I appreciate the help a lot. <3