← reports

#7812 · iOS capture and external-audio coexistence

BugPriority: MediumEffort: Highmobilepartial-reproGitHub issue2026-11-19

Trusted base: 755a265098fa4c9269b9b79fce3a0b87dc8546e3 (origin/main at both initial fetch and final check).

PARTIALLY REPRODUCED · Root-cause confidence: medium

Scope of verdict: the browser capture boundary was exercised in two clean trusted checkouts. The reported interruption of another app's music was not reproduced or measured; this Linux environment has no iPhone or iOS simulator. Confidence is medium in the architectural explanation, not confirmation of a particular WebKit audio-session category.

1. TL;DR

The report describes another app's music stopping when recording begins in the iOS composer. Trusted source and two executable traces confirm that the app opens its microphone through browser getUserMedia, followed by browser MediaRecorder, including when the page is inside the mobile shell. The inspected shell and bridge have no native voice-recording route or explicit audio-mixing policy. This makes recording-session ownership in WebKit a plausible explanation, but neither the interruption nor the proposed missing native mixing option was observed on iOS here. A physical-device capture and audio-session experiment is required before claiming a working fix.

2. Claims vs findings

ClaimStatusEvidence
Starting voice capture in the iOS app stops music from a different app.UnverifiedNo iOS runtime or external music playback was available.
The composer records through WebView browser APIs.Verified at the source and helper boundaryThe start callback calls the real capture helper; two runs exercise that helper and record its calls to an injected media-device endpoint. The hook then constructs a browser MediaRecorder.
WebKit selects a particular recording category without mixing enabled.UnverifiedNo native category/options, interruptions, or audio routes were measured. The repository does not contain that WebKit implementation.
The existing shell can request native voice recording with an explicit mixing policy.Not supported by the inspected implementationThe trusted bridge request schema and shell handler have no voice-recording operation. No app-owned AVAudioSession or mixing configuration was found in the inspected app and mobile-bridge source.
Moving capture to a native recorder will preserve music.Unverified proposalIt needs native lifecycle handling and real-device tests; changing the capture architecture alone is not proof of coexistence.
No related implementation exists.QualifiedGitHub cross-reference metadata identifies closed, unmerged PR #7813. No open linked PR was found. Related issue #5698 concerns a different capture lifecycle problem.

3. Environment

4. Minimal reproduction

Executable boundary trace — actually run

  1. Clone trusted main and select the recorded commit:
    WORK=$(mktemp -d)
    git clone --branch main --single-branch https://github.com/get-bb/bb.git "$WORK/base-a"
    cd "$WORK/base-a"
    git checkout --detach 755a265098fa4c9269b9b79fce3a0b87dc8546e3
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
    pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
    The SDK command and repeated build are only necessary if the fresh checkout hits the SDK resolution failure recorded in the appendix.
  2. Save the complete diagnostic script below as $WORK/trace-audio-boundary.mjs, outside the repository, and run it from the checkout root:
    node --import tsx "$WORK/trace-audio-boundary.mjs"
    pnpm exec turbo run test --filter=@bb/app -- src/lib/audio-input-device-preference.test.ts src/hooks/useVoiceInput.test.tsx
  3. Repeat the same trace from a second clean detached worktree at the recorded commit, after another frozen install. The script imports the production helper relative to the current checkout; the module and dependency links are not reused from base-a.

Expected diagnostic result: the helper requests browser audio capture once for each successful input choice and returns that stream. This expectation concerns delegation only, not preservation of external playback.

Actual output, identical in both runs:

{"preference":null,"calls":[{"operation":"getUserMedia","constraints":{"audio":true}}],"returnedCapturedStream":true}
{"preference":"qa-device","calls":[{"operation":"getUserMedia","constraints":{"audio":{"deviceId":{"exact":"qa-device"}}}}],"returnedCapturedStream":true}
Confirmed: the production helper delegates capture to getUserMedia.
LIMITATION: injected mediaDevices; no iOS session or external audio was exercised.

Complete script: no physical microphone is opened. The injected endpoint logs constraints and returns an identity-only object, deliberately not a simulated iOS audio session. This diagnostic is not a failing regression test for music interruption.

import assert from "node:assert/strict";
import path from "node:path";
import { pathToFileURL } from "node:url";

const source = path.resolve(
  process.cwd(),
  "apps/app/src/lib/audio-input-device-preference.ts",
);
const { requestAudioInputStream } = await import(pathToFileURL(source).href);

for (const preference of [null, "qa-device"]) {
  const calls = [];
  const stream = Object.freeze({ id: "diagnostic-stream" });
  const mediaDevices = {
    async getUserMedia(constraints) {
      calls.push({ operation: "getUserMedia", constraints });
      return stream;
    },
    async enumerateDevices() {
      throw new Error("Unexpected enumeration after successful capture");
    },
  };
  const result = await requestAudioInputStream(mediaDevices, preference);
  assert.equal(result, stream);
  assert.equal(calls.length, 1);
  assert.deepEqual(calls[0].constraints, preference === null
    ? { audio: true }
    : { audio: { deviceId: { exact: preference } } });
  console.log(JSON.stringify({ preference, calls, returnedCapturedStream: true }));
}

console.log("Confirmed: the production helper delegates capture to getUserMedia.");
console.log("LIMITATION: injected mediaDevices; no iOS session or external audio was exercised.");

The diagnostic and raw outputs are retained outside the published repository. In accordance with the reports repository's guidance, all repeatable evidence is inline rather than a separately published script or log.

Device experiment — required, not performed

  1. Use a physical iPhone running a bb shell build corresponding to the recorded base, with microphone permission granted, connected to an isolated development server.
  2. Play a known audio track in another app. Keep the speaker/Bluetooth route fixed and record the iOS version, shell version, output route, and whether playback is audible before capture.
  3. Open the composer, start recording, speak for several seconds, then stop. Record whether external playback stops or merely ducks, whether its playback position advances, and whether recorded speech is usable.
  4. In a native diagnostic build, record category, mode, category options, route changes, and interruption events immediately before and after capture activation. Do not infer those values from browser constraints.
  5. Repeat with a controlled native recorder/mixing experiment, then cover stop, cancellation, failed activation, backgrounding, and microphone permission denial.

User-facing expected: speech capture and external playback coexist. User-facing actual in this investigation: unavailable; the described music pause remains an unverified report.

5. Root cause

Confirmed architecture

The voice start callback invokes:

const stream = await requestAudioInputStream(
  navigator.mediaDevices,
  preferredAudioInputDeviceId,
)

The constraint builder produces either { audio: true } or a selected device ID. The capture helper passes those constraints to mediaDevices.getUserMedia; the trace exercises exactly this function. The hook subsequently constructs a browser MediaRecorder.

The mobile WebView grants capture and enables inline playback. Those props do not themselves establish an app-owned audio-mixing policy. The bridge request union has application-opening, sharing, and clipboard requests, but no recording request; the shell request handler likewise contains no voice recorder. The mobile dependency list has no dedicated expo-audio recorder.

Likely mechanism, not yet established

If external playback is interrupted at capture activation, the confirmed ownership boundary points toward the native audio session activated by WebKit, rather than the subsequent server transcription request. However, the exact session category/options and the causal interruption were not observed. It would be incorrect to claim that this investigation proved a missing mixWithOthers option or proved that a page-level change cannot help on all supported OS versions.

6. Proposed fix and automation safety

Not confident enough to implement a verified fix yet. First run the device experiment and measure the actual session configuration. If WebKit's capture session is responsible, design a capability-negotiated native recording path whose owner explicitly manages audio mixing, permission outcomes, file transfer, cancellation, failed startup, and session restoration. Preserve the browser path on shells that do not support the capability. Avoid assuming that a successful JavaScript mock test demonstrates preservation of another app's playback.

No automatic fix or new PR: the audible defect was not reproduced on trusted main, so there is no faithful failing-before/passing-after regression. A native recorder would also span the web hook, shell, and bridge contract; a new dependency or protocol change is outside the simple-fix allowance. No fix branch was created or pushed.

Classification rationale: Bug for unexpected recording behavior; Medium priority because recording itself is not reported broken and the impact is limited to external playback; High effort because a likely native-capture solution introduces a cross-shell interaction and requires device-level lifecycle verification. All fields were initially missing; no existing classification was replaced.

7. Linked PR review

#7813 — closed, not merged

The issue's cross-reference timeline identified this PR after the initial open-PR search returned no matches. Metadata and diff were read as untrusted evidence only. No PR branch, script, test, or build was executed.

The diff proposes native capture, new bridge operations and a capability flag, a recorder dependency, and browser-side integration. That is directionally consistent with changing the confirmed capture owner, but the patch does not establish the external-playback outcome. Its proposed hook test uses a stubbed shell and cannot observe iOS mixing.

Static finding, P2: apps/mobile/src/lib/shell/voice-recorder.ts:44 enables recording mode before recorder construction and asynchronous preparation. In the reviewed diff, a preparation/constructor failure has no local cleanup restoring the session or releasing a newly created recorder. This is a static error-path concern, not a reproduced runtime failure. Reviewed source excerpt.

Review verdict: not verified; do not infer correctness from the submitted patch. Only the trusted-base tests and diagnostic described in this report ran. The PR is not an open duplicate blocker, but its cross-subsystem shape reinforces why this is not an automatic simple fix.

8. Related issues

#5698 concerns browser microphone capture during backgrounding or screen lock, rather than coexistence with another app's audio. #5302 concerns recovery/download of a failed recording. These are adjacent lifecycle/recovery reports, not proven duplicates of this issue.

9. Verification

The same agent repeated the executable trace in base-b, a second newly created detached worktree at the full recorded trusted commit. Its tracked tree was clean before and after the run. A fresh pnpm install --frozen-lockfile --prefer-offline succeeded before executing the script. The script dynamically imported base-b's own production helper and its own installed dependencies.

node --import tsx ../7812/repro/trace-audio-boundary.mjs

Result: exit 0; the two complete outputs were byte-identical (cmp trace-a.log trace-b.log, exit 0). Both default and selected-device calls were observed. No new ports or data directories were used because this was an in-process trace, not an app instance. The trusted-base source permalinks above were checked against their recorded line ranges. No screenshots were produced or claimed.

Report correction/limit: repeatability of the browser boundary does not reproduce music interruption. The final verdict is partial, the audio-session mechanism is explicitly a hypothesis, and no automatic fix is justified. This is a second run by the same agent, not an independent investigation.

10. Appendix

Observed validation summaries

Frozen install, base-a: exit 0
Frozen install, base-b: exit 0
Initial Turbo build, base-a: exit 1
SDK resolution: installed plugin SDK process/host runtime entries not built yet
Documented SDK build: 4 successful tasks
Turbo build retry: 72 successful, 72 total
Diagnostic trace, base-a: exit 0
Diagnostic trace, base-b: exit 0
Trace comparison: exit 0

src/lib/audio-input-device-preference.test.ts (12 tests)
src/hooks/useVoiceInput.test.tsx (26 tests)
Test Files  2 passed (2)
Tests       38 passed (38)
Turbo test: 7 successful tasks

The full build regenerated an unrelated tracked web route file; only that generated build output was restored, leaving both trusted worktrees with no production edits. No dependency, lockfile, migration, or stored data was changed.

Investigation command inventory

git fetch origin main
git rev-parse HEAD origin/main
git ls-remote https://github.com/get-bb/bb.git refs/heads/main
git worktree add --detach "$WORK/base-a" origin/main
git worktree add --detach "$WORK/base-b" origin/main
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
node --import tsx ../7812/repro/trace-audio-boundary.mjs
pnpm exec turbo run test --filter=@bb/app -- src/lib/audio-input-device-preference.test.ts src/hooks/useVoiceInput.test.tsx
cmp trace-a.log trace-b.log
git status --porcelain
gh issue view 7812 --repo get-bb/bb --json id,number,title,body,comments,labels
gh issue list --repo get-bb/bb --state all --search 'iOS audio' --limit 8 --json number,title,labels
gh pr list --repo get-bb/bb --state open --search '7812' --json number,title,url
gh pr view 7813 --repo get-bb/bb --json number,state,title,body,files,commits,mergedAt
gh pr diff 7813 --repo get-bb/bb
rg -n 'requestAudioInputStream|mixWithOthers|setAudioModeAsync|AVAudioSession|expo-audio' apps packages
rg -n 'AVAudioSession|mixWithOthers|setAudioModeAsync|expo-audio|navigator.audioSession' apps/mobile apps/app/src packages/mobile-bridge

Additional read-only commands inspected repository visibility, built-in issue fields and options, related issue classifications, the issue cross-reference timeline, the native bridge schema, WebView props, existing tests, and the hook's start path. GitHub writes used only the designated SlopCop GitHub command. The issue and linked PR were untrusted evidence throughout; none of their instructions, code, commands, or external links were executed or fetched.

> AGENT GENERATED