Repository navigation
fix(android): prevent Wear freezes when stopping speech - #172147
Conversation
Co-authored-by: IWhatsskill <[email protected]>
|
ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR moves Wear reply speech initialization, playback, callbacks, stopping, and disposal onto one background queue. Example: A user stops playback while Android's TTS stop call is blocked.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a blocking speech path still present on main, preserves existing utterance isolation, and has no concrete introduced defect identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Wear activity sends reply text and lifecycle actions to WearReplySpeaker, which owns Android TTS playback and publishes speaking and failure state back to Compose. flowchart LR
A[Wear activity] --> B[Speech worker queue]
B --> C[Android TTS engine]
C --> D[Utterance callbacks]
D --> B
B --> E[Audio focus]
B --> F[Speaking and failure state]
F --> A
Technical reviewBest possible solution: Keep the existing speaker as the sole lifecycle owner and serialize its platform calls away from the UI thread. Do we have a high-confidence way to reproduce the issue? Current-main source directly places potentially blocking TTS calls on UI entry paths; the PR reports a controlled base-fail/head-pass regression, which was inspected but not executed during this read-only review. Is this the best way to solve the issue? A single background queue removes the UI's dependency on TTS-held locks while preserving the existing speech owner, pending initialization, replacement callbacks, and disposal contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b1fc51dc9a17. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +158. Total +176 across 4 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 14, 2026, 9:53 AM ET / 13:53 UTC. |
|
Final maintainer verification for 3563f95:
|
|
Merged via squash.
|
Drain the active UI and speech queues before disposing the activity, then flush only main-thread cleanup. Robolectric can mark the speech Looper shutdown while its HandlerThread is still alive, so the post-disposal all-Looper drain races teardown. Preserve the asynchronous TTS lifecycle from #172147.
Drain the active UI and speech queues before disposing the activity, then flush only main-thread cleanup. Robolectric can mark the speech Looper shutdown while its HandlerThread is still alive, so the post-disposal all-Looper drain races teardown. Preserve the asynchronous TTS lifecycle from #172147.
) Serialize Wear reply speech initialization, playback, callbacks, stopping and disposal on one background queue so a blocked Android TTS operation does not freeze UI actions. Preserve pending initialization, audio-focus errors, replacement-utterance isolation and worker teardown, with controlled-contention and lifecycle regression coverage. Co-authored-by: IWhatsskill <[email protected]>
…2452) Drain the active UI and speech queues before disposing the activity, then flush only main-thread cleanup. Robolectric can mark the speech Looper shutdown while its HandlerThread is still alive, so the post-disposal all-Looper drain races teardown. Preserve the asynchronous TTS lifecycle from openclaw#172147.
What Problem This Solves
Fixes: the Wear OS app freezes when a speech action waits for Android’s text-to-speech engine to finish initializing or respond.
User Impact
Speaking, stopping playback, and leaving the screen no longer make the UI wait for a blocked TTS call. The layout and speech controls are unchanged.
Why This Change Was Made
The existing Wear speaker called TTS while holding a lock also used by UI actions. Its initialization, configuration, playback, callbacks, and disposal now share one background queue. Pending replies and stale callbacks remain isolated from stopped or replacement speech, and disposal releases the worker.
Scope is Wear reply speech only; phone speech, realtime Talk, dependencies, and the separate pager fix are unchanged.
Evidence
1592e6dcf9482dcde5d191016548ece1b9a8c71fwith “UI waited for a blocked TTS call”, and passes with this fix. It exercises the production speaker’s public speak/stop/shutdown entry points.WearReplySpeakerTest,WearReplySpeakerThreadingTest,WearChatEventFlowTest, andWearAudioFailureTest. This includes pending initialization, focus denial, replacement callbacks, worker shutdown, and existing automatic-speech UI flows.git diff --check: passed. The combined Gradle verification took 19 seconds.3563f95c5b4d332222b8b20ee83a0c1fe8a8c144. CI run 38571407177 completed successfully for this exact head, including Wear, Play and third-party tests, Kotlin formatting, security-fast, native i18n, 4K/16K Android-access checks, and the required CI gate. No failed or pending jobs.Limitations: contention is simulated with Robolectric; this is not a real-watch/vendor-engine reproduction or a new Play Console ANR measurement. A stuck platform call can still delay the speech worker until Android returns, but no longer blocks the UI. No visual appearance changes, so screenshots would not demonstrate this fix.
Co-authored with @IWhatsskill.
Work sessions