Repository navigation
fix: address upstream Chromium shift to enable CoreAudio Tap API for audio capture used in electron's desktopCapturer (🍏 macOS). - #49717
Conversation
|
💖 Thanks for opening this pull request! 💖 Semantic PR titlesWe use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Commit signingThis repo enforces commit signatures for all incoming PRs. PR tipsThings that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
nikwen
left a comment
There was a problem hiding this comment.
Thank you so much for your work on this!
Could you please add "Refs #49607" at the beginning of the PR? That makes it easier for maintainers to find the related issue quickly.
Could you please also move over your docs changes as explained on the electron/website PR?
48d080c to
3ff8e6e
Compare
|
@nikwen Just pushed in the documentation from electron/website#1010. The ported changes reflect all of your suggested adjustments as well :) Had to fix lint issue in this file or else could not commit any documentation changes (pre-commit hook error)? Strange. |
CoreAudio Tap API for audio capture used in electron's desktopCapturer (🍏 macOS).
|
@Bug-Reaper, I opened electron/lint-roller#148 regarding the slugification issue, although we usually don't use special characters like ≥ and I think >= would probably slugify ok. Thanks for reporting the issue.
This is a strange one, because in VS Code with the markdownlint extension it's properly flagged as an error, but running It feels like it might be a |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
Release Notes Persisted
|
🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]>
📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]>
🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]>
📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]>
|
@dsanders11 thanks so much for the follow up! Solid investigation :)
Well that is strange, I'm using macOS 15.2 Sequoia. I rely on Had a thought, maybe stale npm libs on my end? from but alas, after fresh Full log attempting to commitBonus log from just running
I did try two characters for the operator initially. Less-than <= (as two characters) was problematic when placed in titles. Not a bug or anything just a quirk/side-effect.
|
Actually I think that's the explanation for the discrepancy. Be sure to use |
You're right @dsanders11 - Restored Thanks again for your investigation! |
…r audio capture used in electron's `desktopCapturer` (🍏 macOS). (#49740) * fix: Enable CoreAudio Tap API for Audio Capture (🍏 macOS) Co-authored-by: Bug-Reaper <[email protected]> * fix: addressed markdown issue which caused pre-commit hook failure 🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]> * fix: updated docs to cover `desktopCapturer` nuances with macOS 📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Bug-Reaper <[email protected]>
…r audio capture used in electron's `desktopCapturer` (🍏 macOS). (#49739) * fix: Enable CoreAudio Tap API for Audio Capture (🍏 macOS) Co-authored-by: Bug-Reaper <[email protected]> * fix: addressed markdown issue which caused pre-commit hook failure 🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]> * fix: updated docs to cover `desktopCapturer` nuances with macOS 📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Bug-Reaper <[email protected]>
🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]>
📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]>
…r audio capture used in electron's `desktopCapturer` (🍏 macOS). (#49741) * fix: Enable CoreAudio Tap API for Audio Capture (🍏 macOS) Co-authored-by: Bug-Reaper <[email protected]> * fix: addressed markdown issue which caused pre-commit hook failure 🧑🔧 : Ref : #49717 (comment) Co-authored-by: Bug-Reaper <[email protected]> * fix: updated docs to cover `desktopCapturer` nuances with macOS 📝 : PR #49717 Co-authored-by: Bug-Reaper <[email protected]> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Bug-Reaper <[email protected]>
With electron/electron#49717 the desktopCapturer supports system audio for macOS 13 and above. Is was recently fixed in electron/electron#49740 for current electron. This is a preparational step, but: This on its own does not allow audio for screenshare, as its currently hard-coded to only show the "Share Audio" button on windows, see https://github.com/jitsi/jitsi-meet/blob/master/react/features/screen-share/functions.ts#L34
nikwen
left a comment
There was a problem hiding this comment.
Thanks for moving the docs over. Didn't get a chance to take a look at it before it was merged.
| > [!NOTE] | ||
| > Capturing the screen contents requires user consent on macOS 10.15 Catalina or higher, | ||
| > which can detected by [`systemPreferences.getMediaAccessStatus`][]. | ||
|
|
There was a problem hiding this comment.
Question: Would this newline break the NOTE block syntax?
| app.commandLine.appendSwitch('disable-features', 'MacCatapLoopbackAudioForScreenShare') | ||
| ``` | ||
|
|
||
| --- |
There was a problem hiding this comment.
Usually, we don't use horizontal dividers in our docs.
|
|
||
| ### MacOS versions 12.7.6 or lower | ||
|
|
||
| `navigator.mediaDevices.getUserMedia` does not work on macOS versions 12.7.6 and prior for audio capture due to a fundamental limitation whereby apps that want to access the system's audio require a [signed kernel extension](https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/KernelExtensions/KernelExtensions.html). Chromium, and by extension Electron, does not provide this. Only in macOS 13 and onwards does Apple provide APIs to capture desktop audio without the need for a signed kernel extension. |
There was a problem hiding this comment.
We usually break docs lines between 80 and 100 chars as per the docs style guide.
(I know that the surrounding lines do not necessarily do this. We usually still try to follow it in new documentation that we write.)
|
|
||
| Per [Chromium update](https://source.chromium.org/chromium/chromium/src/+/ad17e8f8b93d5f34891b06085d373a668918255e) which enables Apple's newer [CoreAudio Tap API](https://developer.apple.com/documentation/CoreAudio/capturing-system-audio-with-core-audio-taps#Configure-the-sample-code-project) by default, you now must have `NSAudioCaptureUsageDescription` defined in your `Info.plist` to use `desktopCapturer`. | ||
|
|
||
| Electron's `desktopCapturer` will create a dead audio stream if the new permission is absent however no errors or warnings will occur. This is partially a side-effect of Chromium not falling back to the older `Screen & System Audio Recording` permissions system if the new system fails. |
There was a problem hiding this comment.
| Electron's `desktopCapturer` will create a dead audio stream if the new permission is absent however no errors or warnings will occur. This is partially a side-effect of Chromium not falling back to the older `Screen & System Audio Recording` permissions system if the new system fails. | |
| Electron's `desktopCapturer` will create a dead audio stream if the new permission is absent. However, no errors or warnings will occur. This is partially a side-effect of Chromium not falling back to the older `Screen & System Audio Recording` permissions system if the new system fails. |
…r audio capture used in electron's `desktopCapturer` (🍏 macOS). (electron#49717) * fix: Enable CoreAudio Tap API for Audio Capture (🍏 macOS) * fix: addressed markdown issue which caused pre-commit hook failure 🧑🔧 : Ref : electron#49717 (comment) * fix: updated docs to cover `desktopCapturer` nuances with macOS 📝 : PR electron#49717
…n 39.6+ (#138) ## What changes and why A Mac user can now record the other side of a call with **Include system audio** or a **System audio (this computer)** track, on macOS 14.2 or later in an Obsidian installer built on Electron 39.6 or later, without BlackHole and a Multi-Output device. Until now one platform check in `loopbackHost()` (`process.platform !== 'win32'`) refused it with "Recording the system output directly is granted on Windows only", although the capture path (`setDisplayMediaRequestHandler` with `audio: 'loopback'` plus `desktopCapturer`) works on a current Mac, as the reporter verified on macOS 27 with Electron 43. Closes [#137](#137). Chromium captures a Mac's output through Apple's CoreAudio tap, which arrived in macOS 14.2 and became the default in Electron 39 ([electron/electron#49717](electron/electron#49717), and the maintainer's answer in [electron/electron#47490](electron/electron#47490)). The tap also needs the `NSAudioCaptureUsageDescription` key in the app's `Info.plist`, which Electron's default `Info.plist` carries only from v39.6.0 ([electron/electron#49740](electron/electron#49740)). Without the System Audio Recording permission the grant still returns an audio track, created already `ended` and never delivering a sample, with no error raised. Without the Screen Recording permission `desktopCapturer.getSources` rejects with "Failed to get sources", which is what the issue reports. ## Changes Functional: - `grantPlatform()` and `macRefusal()` in `src/recording/systemAudioSupport.ts` grant `darwin` when the host reports macOS 14.2 or later (`process.getSystemVersion()`) and Electron 39.6 or later. A Mac below either floor, or one that reports no version, is refused before the host is asked, so the user never sees the screen-recording prompt only to record silence. The refusal names the version that falls short and, for Electron, points to the installer, because Obsidian's in-app updates do not replace it. - `leadingVersion()` compares the first two numbers as numbers, so `14.10` passes the 14.2 floor and a pre-release such as `43.0.0-beta.4` passes 39.6. - On a Mac, five failures send the user to System Settings > Privacy & Security > Screen & System Audio Recording (Screen Recording on macOS 14), adding Obsidian with the + button if it is not listed, then quitting and reopening Obsidian, and offer BlackHole instead of Stereo Mix or VB-CABLE: a refused source list, no screen, `NotAllowedError`, no audio track, and an audio track that arrives already ended. - The + button is in the step because macOS may never prompt on this path: Electron raises no permission prompt for a source the app picks itself rather than through the system picker ([electron/electron#52738](electron/electron#52738)), so Obsidian can be missing from the list. - `audioOnly()` reads the audio track's state before stopping the video track, so a track that arrived ended (the macOS permission symptom) is told apart from one the video stop took down with it. - `isSystemAudioLoopbackAvailable()` is replaced by `systemAudioGrantSupport()`, which returns `{ refusal, permission }` from one probe of the host. The Windows wording is unchanged, except the answer with no audio track, which no longer says "elsewhere". - The **Include system audio** and **Track N source** rows show the refusal word for word, as a refused recording would end, and show the macOS permission where the grant is available. - System info gains `osVersion`, read by the new `hostSystemVersion()` in `src/platform/hostProcess.ts`, and `systemAudioLoopbackRefusal`. - `docs/use-cases/meeting-notes-workflow.md` covers the macOS route: the permission step with the + button, the version floors, a checklist item and two troubleshooting entries. `docs/troubleshooting.md` gains a "This computer's output is not recorded" section with one entry per refusal reason. `docs/recording.md`, `docs/multi-track-recording.md`, `docs/settings-reference.md`, `docs/features.md`, `docs/index.md` and `README.md` say the same. Release notes are left to the release PR, per `docs/dev/releasing.md`. Tests: - `tests/unit/systemAudioSupport.test.ts` covers granted Macs (the floor itself, the reporter's machine, `14.10`, a bare `26`, `43.0.0-beta.4`), refused Macs (macOS 14.1, 13.x, a missing or empty version, Electron 39.5.2, the Electron 39.2.6 of the Obsidian 1.11.4 installer, Electron 38, a missing or invalid Electron, both too old, a throwing `getSystemVersion`), all refused before `getDisplayMedia` or the handler is touched, and the five Mac permission failures with the + button step, the BlackHole fallback, and an ended-on-arrival track against one ended with the video on both platforms. - `tests/integration/settingsDefinitions.test.ts` covers the macOS permission on both rows, the version reason on an old Mac, no permission text on Windows, and the Linux refusal. - `tests/integration/SystemDiagnostics.test.ts` covers `osVersion` and the refusal reason or null, and `tests/unit/hostProcess.test.ts` covers `hostSystemVersion` absent, empty, throwing and with no process. ## Verification The local gate on [cb5fa63](cb5fa63) is green. `npm run build` passes, and `npm run lint` reports 0 errors and the 2 existing warnings. `npm run test:coverage -- --randomize` (seed 483263896) passes 7759 of 7759 tests in 325 suites. An earlier run of the same tree (seed -310868346) timed out once in `tests/e2e/recordingPanel.e2e.test.ts`, whose test takes 52 ms alone and passes with that seed. `coverage-diff` finds no regression, with total branches at 96.35% against a baseline of 96.22%. `layer-check`, `test-conventions` and `clone-check` stay within their ceilings. The settings rows were rendered from a dump of the real settings tab. On Windows the **Include system audio** and **Track N source** text is unchanged, so `docs/images/settings-audio-input.png`, `settings-include-system-audio.png` and `settings-multi-track.png` still show the current rows and are not replaced. Nothing has run on a real Mac. Every macOS case runs against a mocked `process`, `desktopCapturer` and `getDisplayMedia`. The issue author offered to test a build on macOS before the release, which would confirm the permission messages, the version floors, and whether Obsidian appears in the permission list on its own. ## Risks and what to review first - The Electron floor is 39.6, the first 39.x whose `Info.plist` carries `NSAudioCaptureUsageDescription`. The Obsidian 1.11.4 installer runs Electron 39.2.6, and its DMG holds `NSMicrophoneUsageDescription` but no `NSAudioCaptureUsageDescription`, while the 1.12.4 installer on Electron 39.7.0 holds both, so 1.11.4 is refused with the installer advice instead of being sent to a permission that cannot help. Electron 40.0 to 40.4 lack the key too and would pass the floor, but no Obsidian installer was built on them: the changelog lists 39.2.6, 39.7.0, 39.8.3 and then 43.x. - [electron/electron#52738](electron/electron#52738) is open and describes exactly this call path (`useSystemPicker: false`): the track arrives ended and macOS shows no prompt. The plugin handles it by naming the permission and the + button, and the reporter of [#137](#137) recorded successfully after granting it by hand, but a fix in Electron could change what macOS does on this path. - `systemAudioGrantSupport()` replaces an exported function, and every caller in `src/` was moved to it.

Description of Change
Refs #49607
This PR adds the
NSAudioCaptureUsageDescriptionInfo.plist key required for electron apps to usedesktopCapturer. The key enables Apple's newerCoreAudio Tap APIwhich is the new goto for chromium's plumbing responsible fordesktopCapturer1e3df01Updates documentation for
desktopCapturerpage to bring it up to date with macOS developments. Page has been out of date since macOS 13 when Apple introduced methods for audio-capture w/o a signed kernel extension. bc35ff5Retro-actively adds a breaking change to the
V39.0.0 Breaking Changessection. Breaking change is related to chromium's use of native Apple APIs used in audio capture. bc35ff5Minor lint fix that was tripping up pre-commit hook when I went to add aforementioned docs changes. bc35ff5
🍎 : CoreAudio Tap API Reference
The new plist key is a required permission to use electron's
desktopCapturerproperly on macOS >= 14.2 && electron >= 39.0.0-beta4.Additional Context
Apple quietly released a new API for doing native audio-capture and then didn't communicate well down-stream that a new
Info.plistpermissionNSAudioCaptureUsageDescriptionis required.Hope inclusion of config added in this PR can aid in downstream adoption and awareness of the new permission 🤝
In the Chromium version jump for
v39.0.0-beta.4they make the new native Apple audio API the default. SodesktopCapturerabruptly stops working without the new plist entry in that version and higher. This is b/c chromium has effectively retired the old native API which didn't have plist key reqs. No fallback to the old system exists if the new system fails.Related Website PR : electron/website#1010
Checklist
npm testpassesRelease Notes
Notes: Addressed upstream Chromium shift to enable
CoreAudio Tap APIfor audio capture used in electron'sdesktopCapturer(🍏 macOS).