Skip to content

fix(app): resume phone mic after other-app audio on iPadOS (#4706) - #11146

Merged
kodjima33 merged 4 commits into
BasedHardware:mainfrom
aryanorastar:fix/4706-ipados-audio-interrupt-resume
Aug 6, 2026
Merged

kodjima33 merged 4 commits into
BasedHardware:mainfrom
aryanorastar:fix/4706-ipados-audio-interrupt-resume

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

On iPadOS (Stage Manager / windowed apps), playing YouTube (or other audio) while Omi phone-mic records can stop mic frames without an AVAudioSession interruption. The UI stayed on “Listening”, Dart stall timers may not fire while suspended, and appBecameActive only resumed if already .interrupted. Fixes #4706.

  • Native: on appBecameActive while .running, rebuild if the engine is dead; on interruptionEnded, always attemptResume() once (other-app audio often ends without shouldResume).
  • Dart: probeStallAfterForeground() soft-rearms the stall clock from home lifecycle resume (does not immediately stop→start — native owns dead-engine rebuild; the periodic watchdog escalates only if frames still don’t arrive).
  • UI: any RecordingState.interrupted shows Paused (not only call-active).

Product invariants affected

none

How it was verified

cd app && flutter test \
  test/unit/native_mic_recorder_service_test.dart \
  test/unit/mic_arbiter_test.dart \
  test/unit/voice_recorder_mic_contention_test.dart \
  test/widgets/transcription_paused_warning_test.dart

Could not reproduce on a physical iPad in this environment. Native dead-engine rebuild is covered by the existing PhoneMic control path + unit tests for the Dart timer-suspension gap.

Tests

  • app/test/unit/native_mic_recorder_service_test.dart — soft-rearm / watchdog foreground-stall cases
  • app/test/widgets/transcription_paused_warning_test.dart — non-call interrupted → Paused + paused affordance
  • mic test doubles stub probeStallAfterForeground

Failure class (fixes)

Failure-Class: none

Scoped cleanups (optional)

n/a

…ware#4706)

Heal silent mic death when Stage Manager / YouTube stops capture without an
AVAudioSession interruption: rebuild a dead engine on foreground, always probe
resume when an interruption ends, and trip the Dart stall path after suspended
timers so the UI no longer stays stuck on Listening.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…re#4706)

Detect Hermetic Backend Scope hit the 2m job timeout (cancelled); Merge Gate
fail-closed on SCOPE_RESULT=cancelled. App-only PR — no backend scope change.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

CI note: Backend Hermetic Merge Gate red is not from this PR’s app changes.

Same flake as #11144: Detect Hermetic Backend Scope hit the 2m job timeout and was cancelled → Merge Gate fail-closed on SCOPE_RESULT=cancelled (E2E correctly skipped). No admin rights to gh run rerun; empty commit retriggers checks.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found and verified against the latest diff

Confidence score: 5/5

  • In app/lib/pages/conversations/widgets/processing_capture.dart, the new non-call RecordingState.interrupted path is unguarded by a widget regression test, so a future UI refactor could silently stop showing Paused (or its paused affordance) for isCallActive == false, confusing users about capture state — add a widget test that asserts both elements for that scenario.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/lib/pages/conversations/widgets/processing_capture.dart">

<violation number="1" location="app/lib/pages/conversations/widgets/processing_capture.dart:364">
P3: The new non-call `RecordingState.interrupted` rendering has no widget regression test; add one with `isCallActive == false` that asserts `Paused` and the paused affordance so this UI contract cannot regress.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

bool isCallInterrupted = provider.recordingState == RecordingState.interrupted && provider.isCallActive;
// Any audio-session interruption (call, other-app audio, system alert) is
// treated as paused so the UI does not claim "Listening" while mute (#4706).
bool isAudioInterrupted = provider.recordingState == RecordingState.interrupted;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new non-call RecordingState.interrupted rendering has no widget regression test; add one with isCallActive == false that asserts Paused and the paused affordance so this UI contract cannot regress.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/pages/conversations/widgets/processing_capture.dart, line 364:

<comment>The new non-call `RecordingState.interrupted` rendering has no widget regression test; add one with `isCallActive == false` that asserts `Paused` and the paused affordance so this UI contract cannot regress.</comment>

<file context>
@@ -346,37 +350,39 @@ class _ConversationCaptureWidgetState extends State<ConversationCaptureWidget> {
-    bool isCallInterrupted = provider.recordingState == RecordingState.interrupted && provider.isCallActive;
+    // Any audio-session interruption (call, other-app audio, system alert) is
+    // treated as paused so the UI does not claim "Listening" while mute (#4706).
+    bool isAudioInterrupted = provider.recordingState == RecordingState.interrupted;
     bool isPaused = false;
     if (isDeviceRecording) {
</file context>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 6d695a2 — see PR comment for details.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strengthened in the follow-up push: the #4706 widget test now asserts Paused text, the orange paused status dot, and the play (resume) affordance for isCallActive == false.

Also fixed Dart Analyze: test doubles implementing IMicRecorderService now stub probeStallAfterForeground() (that was the red CI).

Address cubic review: foreground must not race native rebuild or false-
restart healthy sessions. Soft-rearm the stall clock instead of escalating
immediately; add widget coverage for non-call interrupted → Paused; reformat
Dart for CI.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Follow-up @6d695a20 (cubic + Formatting)

Addressed all three cubic findings:

  1. P2 dual recovery — foreground no longer Dart stop→starts; soft-rearms stall clock only. Native owns dead-engine rebuild.
  2. P2 false stall — wall-clock silence from suspension alone no longer escalates; watchdog still catches real post-resume silence.
  3. P3 UI test — widget coverage for non-call interrupted → Paused.

Also re-ran dart format --line-length 120 on the touched Dart files (Formatting CI was red on the previous push).

…rdware#4706)

Dart Analyze CI failed: FakeMic / _ContendedMic missing the new
IMicRecorderService method. Also tighten BasedHardware#4706 widget coverage to assert
Paused text plus orange status-dot and play affordance.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

CI fix

Dart Analyze & Tests failed because FakeMic / _ContendedMic did not implement the new IMicRecorderService.probeStallAfterForeground() — compile-time, never baselined.

Fixed + pushed; widget test also asserts paused affordance (orange status dot + play icon) per cubic P3.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge ios labels Aug 5, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this — clean, well-scoped fix for a real iPadOS edge case (#4706: other-app audio silently killing the phone-mic engine without an AVAudioSession interruption, leaving the UI stuck on "Listening" while mute).

A few notes from review:

  • The split of responsibility reads correctly: native appBecameActive owns dead-engine rebuild, while probeStallAfterForeground() on the Dart side only soft-rearms the stall clock instead of forcing a stop→start. Avoiding that Dart-side escalation racing the native rebuild is the right call, and the test in native_mic_recorder_service_test.dart covers both the soft-rearm and the genuine post-resume silence path.
  • Generalizing the interrupted→Paused UI display (not only isCallActive) is a good correctness improvement; the widget test asserts the affordance.
  • The interruptionEnded change to always attemptResume() once is reasonable given that other-app audio frequently ends without shouldResume. The ticker keeps probing if bring-up is still blocked, so the failure path stays safe.

I see the prior cubic-dev-ai findings (dual-recovery race, false-stall on suspended timers, missing UI test) were all addressed in the follow-up commit, and CI is green.

One thing a maintainer should confirm on a physical iPad before merge: the appBecameActive + .running + dead-engine rebuild path can't be exercised by CI, so a quick on-device smoke (Omi recording → launch YouTube/Stage Manager → return to Omi → verify frames resume) would close the loop. No code changes requested from this review.

Leaving for a human maintainer to verify the on-device behavior and merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level Thanks for the positive signal.

Agreed on the iPad smoke gap — no physical iPad in this environment, so that path stays an honest verification hole for a maintainer with device access (Omi recording → YouTube/Stage Manager → return → frames resume).

No further author code changes pending on this head; CI green @b82fb8ca including the soft-rearm + widget-affordance follow-ups.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level need human response

Head @b82fb8ca is fully green (Dart Analyze, Android Compile, Preflight). Cubic findings addressed; your positive-signal pass found no code changes. Remaining gap is honest: physical iPad smoke (Omi recording → YouTube/Stage Manager → return → frames resume).

Merge still blocked solely on write-access APPROVE. Could a human maintainer with device access smoke + APPROVE/merge when you have a moment? No further author work pending.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebuilds the dead phone-mic engine on foreground and always retries on interruptionEnded; covers the iPadOS other-app-audio stall.

@kodjima33
kodjima33 merged commit e7bb7e9 into BasedHardware:main Aug 6, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ios needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recording stops / stuck when other audio plays — Omi does not auto-resume (iPadOS)

3 participants