Skip to content

fix(android): prevent Wear freezes when stopping speech - #172147

Merged
roboclaw-bot merged 1 commit into
mainfrom
fix/wear-tts-ui-freeze
Oct 14, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
fix/wear-tts-ui-freeze

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • The new controlled-contention regression fails against unmodified base 1592e6dcf9482dcde5d191016548ece1b9a8c71f with “UI waited for a blocked TTS call”, and passes with this fix. It exercises the production speaker’s public speak/stop/shutdown entry points.
  • 114/114 tests pass across WearReplySpeakerTest, WearReplySpeakerThreadingTest, WearChatEventFlowTest, and WearAudioFailureTest. This includes pending initialization, focus denial, replacement callbacks, worker shutdown, and existing automatic-speech UI flows.
  • Wear debug APK build, Android lint, Kotlin formatting, and git diff --check: passed. The combined Gradle verification took 19 seconds.
  • Independent AutoReview (Codex, P0–P2): completed with no actionable findings. Speaker tests took 0.03 seconds; existing app-flow coverage took 11.47 seconds (Robolectric test time).
  • Head: 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

@roboclaw-bot roboclaw-bot added the maintainer Maintainer-authored PR label Oct 14, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 14, 2026 13:23
@clawsweeper

clawsweeper Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment @clawsweeper review. Please avoid repeated requests while a review is queued or running; agents should not request reviews automatically.

@IWhatsskill

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The UI waits inside the synchronous speech operation.
  • After: The UI queues the stop and remains responsive while the speech worker waits.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and has useful contention and lifecycle coverage, with confidence limited by simulated Android TTS behavior.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; its production speaker is exercised through Robolectric speak/stop/shutdown calls, with real-watch behavior explicitly unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Wear speech actions can freeze the interface while Android's TTS engine is blocked.
Reason: The focused change addresses a concrete responsiveness defect, and collaborator authorship supplies the direction decision.

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
Reviewed head: 3563f95c5b4d332222b8b20ee83a0c1fe8a8c144

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Real-watch TTS contention and responsive stop/disposal remain unverified; supplied coverage uses Robolectric platform shadows.
Agent review details

How this fits together

The 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
Loading

Technical review

Best 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

  • Wear reply speech serialization and callback isolation keeps the original intent (cf763c0: Protect pending initialization, error reporting, audio focus, and replacement utterances from stale callbacks.)
  • Wear companion speech lifecycle keeps the original intent (9dedacf: Restore the complete companion experience, including local reply speech and automatic speech controls.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • WhatsSkiLL: Raw commit 9dedacf adds apps/android/wear/src/main/java/ai/openclaw/wear/WearReplySpeaker.kt:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9dedacf57792; files: apps/android/wear/src/main/java/ai/openclaw/wear/WearReplySpeaker.kt)
  • RoboClaw: Raw commit cf763c0 adds apps/android/wear/src/main/java/ai/openclaw/wear/WearReplySpeaker.kt:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cf763c01a46e; files: apps/android/wear/src/main/java/ai/openclaw/wear/WearReplySpeaker.kt)

PR surface

Source +18, Tests +158. Total +176 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 88 70 +18
Tests 3 163 5 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 251 75 +176

Labels

Label changes:

  • add P2: The fix addresses a Wear speech UI hang with limited platform scope; current evidence does not establish a widespread urgent regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The fix addresses a Wear speech UI hang with limited platform scope; current evidence does not establish a widespread urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture responsive Wear speech and stop/disposal behavior on a real watch with the platform TTS engine.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 14, 2026, 9:53 AM ET / 13:53 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Final maintainer verification for 3563f95:

  • Reviewed all four changed files and the existing speech lifecycle. WearReplySpeaker remains the sole owner; one background queue handles initialization, playback, callbacks, stop and disposal without making UI callers take a TTS-held lock. No further code changes were needed.
  • Independent AutoReview and the latest exact-head ClawSweeper review report no actionable findings or before-merge repairs. Pending initialization, audio-focus failure, replacement utterances, late callbacks and worker teardown remain covered.
  • Earlier same-session verification passed 114/114 targeted tests, Wear APK assembly, Android lint, Kotlin formatting and diff checks. The controlled-contention regression fails on the unmodified baseline and passes on this source.
  • Exact-head CI run 38571407177 completed successfully, including Wear, Play, third-party, native i18n, formatting, security and 4K/16K Android-access checks. Required CI gates pass.
  • Limits: contention uses Robolectric shadows, not a physical watch/vendor-engine replay or a new Play Console ANR measurement. A stuck engine can still delay the worker, but not the UI entry points. No visual appearance change.
  • Native exact-head review validation and prepare-run completed without rewriting or pushing the source. Preparation records github_pending; merge-run will revalidate live CI and current-main composition before the authorized squash dispatch.

@roboclaw-bot
roboclaw-bot merged commit 9dfaff2 into main Oct 14, 2026
154 of 156 checks passed
@roboclaw-bot
roboclaw-bot deleted the fix/wear-tts-ui-freeze branch October 14, 2026 14:05
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 14, 2026
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.
steipete added a commit that referenced this pull request Oct 14, 2026
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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
)

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: wearos App: wearos maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants