Skip to content

fix(app): treat a missing pendant mute feature as legacy and retry a failed read - #26041

Merged
kodjima33 merged 1 commit into
mainfrom
mux/2026-11-22-pendant-mute-read
Nov 22, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
mux/2026-11-22-pendant-mute-read

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Crashlytics issue faed8329 is the #2 iOS issue this week: 159 users in 7 days (52, 49 and 35 a day on Nov 20 to 22), on 1.0.592 to 1.0.596. Crashlytics counts it as NON_FATAL, but every event carries error_origin = uncaught_async, so it reaches the global uncaught handler instead of a handled pause failure. Source: Crashlytics BigQuery (com_friend_app_with_wearable_ios12_IOS_REALTIME), runs/2026-11-22/analysis/voice.md.

Verified cause, from the stack traces (266 events, 7 days, one shape):

OmiDeviceConnection.setCaptureMuted  omi_connection.dart:1364
CaptureController._writeDeviceMute  capture_controller.dart:4831 (1.0.595)
CaptureCoordinator._run              capture_coordinator.dart:1613
CaptureCoordinator._pump.<fn>        capture_coordinator.dart:1507
"Bad state: Unable to confirm device mute capabilities"
  • setCaptureMuted (omi_connection.dart:1364) throws whenever the features read is shorter than 4 bytes. NativeBleTransport.readCharacteristic (native_ble_transport.dart:315) returns [] for a characteristic missing from the GATT table, for a 10 s timeout and for any platform error. So the app cannot tell old firmware (where the doc comment promises a no-op) from a failed read.
  • The coordinator catches the error, but pauseCapture(), resumeCapture() and streamDeviceRecording() rethrow it via throwIfFailed() with the original stack. Any caller that does not await and catch turns it into uncaught_async. quick_actions_service.dart:206-208 is one such caller.
  • The Crashlytics log tail before each event is repeated "Omi Device Disconnected", so many events look like a write issued while a reconnect is settling, not only legacy firmware. Half the events are from a backgrounded app.

Change

No UI change. No change to the BLE protocol, UUIDs, firmware expectations, or connection and reconnect logic.

  • omi_connection.dart setCaptureMuted: if the native transport has a discovered GATT table and the features characteristic is not in it, return as the documented legacy no-op. Otherwise a short or failed features read waits 500 ms and retries once, then throws as before. "Not discovered yet" is never treated as legacy: that would report a pause the pendant never applied.
  • native_ble_transport.dart: read-only servicesDiscovered getter (no behavior change).
  • quick_actions_service.dart: the mute and unmute shortcuts catch a failure and report it with reportNonFatal and capture_mute_source=quick_action, capture_mute_action=mute|unmute.

UI state after a failed write: the coordinator fails closed, so capture state stays as it was. The live page, Home card and device settings show "Something went wrong" (unchanged). The quick action has no screen, so a failed shortcut pause shows nothing to the user; its shortcut label follows the unchanged capture state. Not redesigned here.

Impact estimate

If the missing feature is a no-op and a failed read retries once, faed8329 non-fatal users go 159/week → near 0 (range 0 to ~80, MODELED). Churn effect unmeasured.

  • Base 159 users/7 d: ACTUAL, Crashlytics BigQuery, runs/2026-11-22/raw/crashes.json.
  • Share removed: MODELED. The legacy case goes to 0. The transient case goes to 0 when the retry succeeds. Which case dominates is unknown: these events carry no firmware or discovery key. A read that fails twice still throws and is still uncaught from callers outside this diff (below), hence the upper bound of about half.
  • Crashlytics type: NON_FATAL today, and it stays non-fatal. No app crash is involved.

Evidence

No visible change, so no screenshots. A simulator has no pendant. Unit tests with fake transports:

Case main this PR
Features characteristic absent after discovery (native transport) throws no-op, no read, no write
Before discovery (native transport, empty table) throws throws (not taken as legacy)
Features read fails once, then succeeds throws retries, writes the pause
Features read fails twice throws after 1 read throws after 2 reads, no write
Quick action mute/unmute fails uncaught async error fails the test reported non-fatal with source + action

The first, third, fourth and fifth tests fail on main (run with hook-free copies of the tests against main's lib/).

BLE review needed

This touches app/lib/services/devices/** (CODEOWNERS: @mdmohsin7). Recent authors of that folder (30 days): @Git-on-my-level (9), @apoorvdarshan (wrote the mute guard, f97e6bf), @deromka. Asking @apoorvdarshan and @Git-on-my-level to review, since the CODEOWNERS entry may be stale.

Device tests needed (not run)

  • Omi CV1 on current firmware: pause and unmute from the app and from the iOS quick action, 5 times each. Check that the pendant mute characteristic follows each one.
  • An older-firmware pendant without the features characteristic: pause and unmute from the app and the quick action. Expect no error and a local-only pause.
  • Reconnect while paused on CV1: the pendant stays muted.

At ship

  • No flags, no new events, no keep-list change.
  • Calibration read: faed8329 users per day on the first build with this change, against 35 to 52 a day now.

Product invariants affected

  • INV-CAP-1 (pendant audio retention): kept. The change only decides whether a deliberate pause or unmute reaches the pendant. It never closes, unsubscribes or fences an uplink. A legacy pendant has no device mute, so the app's local pause stays the only gate, as before fix(firmware): persist CV1 pause/mute across Bluetooth disconnect #14293. An unmute that fails twice still fails closed in the coordinator and the error stays visible.

Tests

  • flutter test test/unit/omi_capture_mute_ble_test.dart test/services/quick_actions_service_test.dart test/unit/capture_policy_test.dart test/providers/capture_provider_test.dart test/unit/native_ble_transport_resync_test.dart test/services/devices/transports/native_ble_transport_test.dart: 167 passed.
  • make preflight: passed. UX contract, UI isolate and brand checks are clean on the changed files.

Not verified

  • No real pendant was used. Every BLE claim above comes from code and tests.
  • Which empty-read case dominates in the field.
  • Callers outside this diff still rethrow a double failure without catching it. Examples: DeviceProvider._onDeviceConnected (device_provider.dart:1129, a void async that awaits streamDeviceRecording at 1190) and the Home post-frame callback (pages/home/page.dart:523-529). Catching there changes reconnect control flow, which this PR leaves alone. Those are follow-ups for the BLE owners.

Failure-Class: FC-empty-ble-read-taken-as-capability

Line-Count-Exception: app/lib/services/devices/connectors/omi_connection.dart | 1580 -> 1604 | the legacy check and one retry belong next to the mute write they guard; splitting the connector is out of scope for a crash fix

UI-Evidence: none -- no visible change; quick_actions_service.dart only gains error handling (code and unit tests)

View guided diff Turn on auto-fix

…failed read

setCaptureMuted threw 'Unable to confirm device mute capabilities' whenever
the features read came back short. The native transport returns an empty
read both for a characteristic the firmware lacks and for a failed read, so
legacy pendants were refused and a read during a reconnect failed the pause.

A discovered GATT table without the features characteristic is now the
documented legacy no-op. Any other short read retries once before throwing.
The quick action mute and unmute now report a failure as a non-fatal instead
of leaving it uncaught.
@kodjima33 kodjima33 added the mux-proposal Mobile UX improver (MUX) proposal; waits for Nik's ship label Nov 22, 2026
@kodjima33
kodjima33 marked this pull request as ready for review November 22, 2026 12:28
@kodjima33
kodjima33 requested a review from mdmohsin7 as a code owner November 22, 2026 12:28
@kodjima33
kodjima33 merged commit 7da518a into main Nov 22, 2026
63 of 66 checks passed
@kodjima33
kodjima33 deleted the mux/2026-11-22-pendant-mute-read branch November 22, 2026 12:28
@kodjima33

Copy link
Copy Markdown
Collaborator Author

Merged after an independent review (SHIP, no must-fixes). Two things are still open for the BLE owners, @apoorvdarshan @Git-on-my-level:

  1. Does the Android connection code ever refresh the GATT cache after an OTA update? The app bonds with the pendant, and nothing calls a refresh. A phone whose cached table predates the features characteristic (19b10021) would now be treated as legacy firmware, so a pause would skip the device mute without an error. On main that case threw.
  2. Device tests not run (no pendant on the build machine): CV1 on current firmware, pause/unmute from the app and from the quick action 5 times each; an older-firmware pendant without the characteristic; reconnecting while paused.

If either shows a problem, revert 7da518a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mux-proposal Mobile UX improver (MUX) proposal; waits for Nik's ship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant