mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3382] [Issue]: TTS clip is dropped (not played) when the tab is unfocused as generation finishes #1832
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#1832
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 (Jul 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3382
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
If you trigger TTS and switch away from the tab before the audio finishes generating, the clip is dropped instead of played. TTS is fetched asynchronously and
Audio.play()is called only after the fetch resolves — so if the tab is hidden at that moment, the browser's autoplay policy rejectsplay()and the clip is discarded (an error state is set, but nothing is played or retried).How to reproduce (try it yourself)
You'll see: the clip never played (state went to an error / "Browser blocked audio playback"), and it isn't retried when you return.
Expected: the clip plays when you return to the tab — it should be queued and played on the next focus/visibility change instead of being dropped.
Where it is
packages/client/src/lib/tts-service.ts— the audio element is created after the async fetch:blob = await this.getAudioBlob(...)(192), thenconst audio = new Audio(objectUrl)(218), thenawait audio.play()(235). The catch (236-243) handles a rejectedplay()by callingthis.cleanup()andsetState("error")with "Browser blocked audio playback" — there's no queue or retry. A search forvisibilitychange/document.hiddenin this file finds nothing, so a hidden tab at play-time is unhandled.What's happening
Browser autoplay policy blocks
play()for audible media when the document is hidden and there's no fresh user gesture by the time the async fetch resolves. Because the play call happens post-fetch, a tab switch during generation lands exactly in that blocked window, and the code treats the rejection as a terminal error rather than a deferrable one.Suggested fix
When
audio.play()rejects (ordocument.hiddenis true at play-time), don't discard the clip — hold it and retry playback on the nextvisibilitychange/focus, guarded so it only plays if it's still the current sequence. Revoke the object URL if the user has moved on. This keeps the existing "generate-then-play" flow but survives a backgrounded tab.AI-investigated against the current tree; the post-fetch
new Audio().play()path, the terminal-error catch, and the absence of any visibility handling were all read and confirmed. Please verify before fixing.@SpicyMarinara commented on GitHub (Jul 8, 2026):
Addressed in #3388 and merged to staging.