Avoid redundant default-voice Binder calls during Android initialization - #654
Open
Wackymax wants to merge 1 commit into
Open
Avoid redundant default-voice Binder calls during Android initialization#654Wackymax wants to merge 1 commit into
Wackymax wants to merge 1 commit into
Conversation
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.
Both Android initialization callbacks query
TextToSpeech.defaultVoice, check its language, and apply that language again. These synchronous service calls can block the initialization callback on Binder IPC and voice-list deserialization; a production ANR was captured inonInitListenerWithoutCallback -> TextToSpeech.getDefaultVoice -> isLanguageAvailable -> BinderProxy.transact.Remove the redundant default-language blocks from both callbacks. Android's own
SetupConnectionAsyncTaskalready stores the engine's default language and voice before dispatchingonInit(AOSP source). The plugin continues to register its utterance listener, drain pending calls, and completesetEngine. Explicit language and voice APIs retain their existing behavior. In particular, a queuedsetLanguagerequest is no longer overwritten by the subsequent default-language reset.Related to #594, which identifies the same initialization ANR and proposes moving the calls to a worker thread alongside changes to pending-call handling. This is a smaller alternative for the redundant default-language work; it does not attempt to fix all TTS Binder operations or pending-call concurrency.
Validation: four parameterized Android JVM regression cases cover both initialization callbacks, verify that initialization performs no default-voice/language service calls, and verify that an explicit language request queued before initialization is preserved. Physical-device latency and engine-specific default-voice behavior still need validation.
The regression tests failed in all four cases against unpatched
masterand passed in all four cases with the fix. Command:./gradlew --no-daemon --no-configuration-cache -PskipDependencyChecks=true :flutter_tts:testDebugUnitTestfromexample/android. Local test setup used JDK 21, Gradle 8.13, and the installed NDK 28.2; the newer local Flutter SDK required the version-check bypass. These example/toolchain adjustments are not included in this PR.