Skip to content

fix(macos): resolve microphones Chromium labels with a transport suffix - #1147

Merged
EtienneLescot merged 1 commit into
mainfrom
fix/1143-macos-mic-chromium-suffix
Oct 12, 2026
Merged

EtienneLescot merged 1 commit into
mainfrom
fix/1143-macos-mic-chromium-suffix

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The macOS ScreenCaptureKit helper maps the renderer's microphone choice (a hashed Chromium id plus its label) to an AVFoundation input by name. Chromium builds that label from the CoreAudio name plus one suffix per transport type: (Built-in), (Virtual), (Aggregate), (Bluetooth), or the USB (vvvv:pppp) pair. #648 taught the resolver the USB pair only, so a chosen BlackHole 2ch (Virtual) (AVFoundation: BlackHole 2ch, BlackHole2ch_UID) fell back to the default input with the "could not be identified" toast.

resolveMicrophoneDeviceID now:

  1. takes a native id when one matches (unchanged),
  2. takes an exact, unique name (unchanged; an input literally named AirPods Pro (Bluetooth) still wins),
  3. otherwise removes one known Chromium suffix and takes a unique match.

Unknown or lowercase suffixes, doubled suffixes and Chromium's Default - ... entry still resolve to nothing, and a name two inputs share stays ambiguous, so the helper keeps falling back to the default and saying so.

Related issue

Fixes #1143

Candidate for cherry-pick to release/v2.1.0 (the candidate at 9c55596 has the same resolver).

Type of change

  • Bug fix
  • Feature
  • Enhancement
  • Documentation
  • Refactor / maintenance
  • Performance
  • Security

Release impact

  • Patch
  • Minor
  • Major / breaking change
  • No release note needed

Desktop impact

  • Windows
  • macOS
  • Linux
  • Installer / packaging
  • Not platform-specific

Screenshots / video

None, no UI change.

Testing

  • swift test --package-path electron/native/screencapturekit: 65 tests, 0 failures. New cases use real macOS labels beside the AVFoundation uniqueID/localizedName pairs for the same inputs (BlackHole, built-in mic, AirPods, Shure MV7 over USB, an aggregate device), plus ambiguity, the Default - ... entry and unknown suffixes.
  • The new suffix cases fail on main (4 labels resolve to nil, and the BlackHole take resolves to device(nil)), pass with the fix.
  • On this Mac, AVFoundation lists the input as BlackHole2ch_UID | BlackHole 2ch, the name the stripped label now matches.
  • Swift-only change, no TypeScript touched.

Manual check remaining: a real HUD take on macOS with two inputs, choosing the non-default one (e.g. BlackHole 2ch (Virtual) while the built-in mic is the default), to confirm no fallback toast and the right input in the audio.

Summary by CodeRabbit

  • Bug Fixes
    • Improved microphone selection for Chromium labels with recognized device suffixes, including USB, Bluetooth, virtual, aggregate, and built-in labels.
    • Preserved safeguards against ambiguous matches and default entries being treated as devices.
  • Tests
    • Added coverage for decorated microphone names, virtual inputs, and ambiguous matches.

Chromium appends (Built-in), (Virtual), (Aggregate) or (Bluetooth) to a
macOS input's name, besides the USB vendor:product pair already handled.
The ScreenCaptureKit helper only stripped the USB pair, so a chosen
BlackHole 2ch (Virtual) fell back to the default input. Strip one known
suffix after the exact match fails, keeping ambiguous names unresolved.

Fixes #1143
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4fb033b0-3a9e-42cf-a6e8-7eced5a83dc8

📥 Commits

Reviewing files that changed from the base of the PR and between 9c55596 and d8fa373.


📒 Files selected for processing (2)
  • electron/native/screencapturekit/Sources/OpenScreenCaptureCore/MicrophoneDeviceSelection.swift
  • electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/MicrophoneDeviceSelectionTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.



📝 Walkthrough

Walkthrough

The macOS microphone resolver now recognizes Chromium’s transport and USB suffixes when matching selected device names. It retains exact-name matching and rejects ambiguous matches. Tests cover suffix handling and microphone selection behavior.

Changes

Microphone device selection

Layer / File(s) Summary
Suffix-aware microphone matching
electron/native/screencapturekit/Sources/OpenScreenCaptureCore/MicrophoneDeviceSelection.swift, electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/MicrophoneDeviceSelectionTests.swift
The resolver removes one recognized Chromium suffix before matching the remaining name. It returns an ID only for a unique match. Tests cover supported suffixes, exact names, default entries, and ambiguous matches.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to d8fa3

No actionable issue is established; the change is mergeable after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the macOS fix for resolving Chromium microphone labels with transport suffixes.
Description check Passed The description is complete and follows the required template. It explains the change, issue, scope, release impact, platform impact, testing, and the remaining manual verification.
Linked Issues check Passed Issue #1143 requires macOS microphone labels with Chromium transport suffixes to resolve to the selected AVFoundation input. The resolver now removes one recognized Built-in, Virtual, Aggregate,…
Out of Scope Changes check Passed The diff changes only the macOS microphone resolver and its focused XCTest suite. The added tests verify the linked issue behavior and preserve existing ID-first, exact-name, USB-suffix, and ambiguity…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EtienneLescot
EtienneLescot merged commit 3217fde into main Oct 12, 2026
19 checks passed
@EtienneLescot
EtienneLescot deleted the fix/1143-macos-mic-chromium-suffix branch October 12, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS records the default microphone when the chosen one carries a Chromium suffix like (Virtual)

1 participant