mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5890] [MERGED] fix(tts): stop Safari's blocked-autoplay retry loop from freezing the tab #6981
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#6981
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5890
Author: @kolacheee
Created: 9/6/2026
Status: ✅ Merged
Merged: 9/6/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5889-tts-safari-play-loop📝 Commits (5)
15c9914fix(tts): stop Safari's blocked-autoplay retry loop from freezing the tab (#5889)cbee321Merge branch 'staging' into fix/5889-tts-safari-play-loop575cef4fix(tts): settle real errors before releasing parked playback (CodeRabbit)23b4a91fix(tts): surface the blocked state from resume and restart too (CodeRabbit)2abe86atest(tts): assert the blocked state per playback path, not by count (CodeRabbit)📊 Changes
10 files changed (+492 additions, -29 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/package.json(+1 -1)📝
packages/client/src/components/chat/ChatArea.tsx(+16 -0)📝
packages/client/src/components/chat/ChatMessage.tsx(+4 -3)📝
packages/client/src/components/panels/settings/TTSConfigCard.tsx(+5 -5)📝
packages/client/src/lib/tts-audio-cache.ts(+56 -9)📝
packages/client/src/lib/tts-service.ts(+108 -11)📝
packages/client/src/localization/locales/en.json(+1 -0)➕
scripts/regressions/tsconfig.client-lanes.json(+15 -0)➕
scripts/regressions/tts-safari-play-guard.regression.ts(+285 -0)📄 Description
Linked issue
Closes #5889
Why this change
A user reported "TTS freezes my whole Marinara instance" — Safari on macOS and iOS, any voice, autoplay or manual, cured only by disabling TTS. The investigation (recorded on the issue) exonerated the server (
/speakis a stateless binary proxy; audio never enters chat data) and pinned the freeze on the client: Safari rejectsaudio.play()withNotAllowedErrorwhen there's no live user activation, andplayWhenAvailabletreated that as "wait until the tab is visible and focused" — which it already was — so it retried with zero backoff, forever: a promise and a DOMException per iteration until the tab froze and WebKit killed it. Manual play hits the same wall because the click's activation expires while the synthesis fetch is awaited.What changed
NotAllowedErrorin a visible tab,playWhenAvailablewaits on a one-shot user-gesture listener (pointerdown/keydown/touchend); the retriedplay()lands inside that gesture's transient activation, which is exactly what makes Safari allow it. One mechanism covers autoplay and manual play — the fresh-Audio-per-chunk architecture rules out per-element gesture priming, so this is deliberately not the play-then-swap-src pattern."blocked"TTS state with honest UX: ChatArea shows a localized "tap anywhere or press any key to play" toast (id-deduped, dismissed the moment playback resumes), ChatMessage counts blocked as busy, and the settings preview button treats blocked as stoppable.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
tts-safari-play-guardlane drives the real exportedplayWhenAvailablewith stubbed globals. The central assertion is the bug's own signature: a blocked visible tab makes exactly oneplay()call in a 300 ms window (the old code: thousands), a gesture earns exactly one retry, the cap ends a hopeless loop at 20 with the policy error surfaced, non-policy errors never retry, and the byte/alias cache accounting is exact.@marinara-engine/sharedfrom source, because fresh-checkout CI lints before anything builds shareddist/. Verified by simulation: client lint passes withpackages/shared/distrenamed away.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
The visible change is the tap-to-play toast and the preview button's stop state while blocked — both need a real Safari session to demonstrate (see manual verification).
Summary by CodeRabbit
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.