fix: add playback timeout safeguard to AndroidTextToSpeechController#1071
Open
lokhor wants to merge 2 commits into
Open
fix: add playback timeout safeguard to AndroidTextToSpeechController#1071lokhor wants to merge 2 commits into
lokhor wants to merge 2 commits into
Conversation
…roller When Android TTS drops an onDone/onError callback (audio routing interference, engine glitch), completePlaybackIfDrained waits forever with non-empty utteranceIds and never emits SpeakingStopped, leaving the UI stuck on 'Speaking response...'. Add a 30-second safety-net timeout that fires after the final chunk is queued. If TTS callbacks haven't drained all utterances by then, the timeout force-cleans the playback state and emits SpeakingStopped. Cancels automatically on natural completion or explicit stop().
Debug APK readyCommit: Updated on each push. Removed when PR is merged or closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Android TTS drops an
onDone/onErrorcallback (audio routing interference, TTS engine glitch, system load),completePlaybackIfDrained()waits forever with non-emptyutteranceIds—SpeakingStoppedis never emitted and the UI stays stuck on "Speaking response…".This happens on the Samsung device after wake word → STT → command → TTS starts → callback never fires.
Fix
Added a 30-second safety-net timeout (
PLAYBACK_TIMEOUT_MS) inAndroidTextToSpeechControllerthat fires after the final TTS chunk is queued. If utterance callbacks haven't drained all pending utterances by then, it force-cleans the playback state, releases audio focus, and emitsSpeakingStopped.speak()/append(isFinal=true)— schedule timeout after final enqueuecompletePlaybackIfDrained()— cancel timeout on natural completionstop()— cancel timeout on explicit stopLog.won forced timeout for diagnosticsTesting
:core:voice:compileDebugKotlin— passes:core:voice:testDebugUnitTest— all tests pass