Skip to content

perf(gpui): check the hotkey's microphone by name on macOS - #2467

Draft
AatmanAJ wants to merge 1 commit into
CapSoftware:mainfrom
AatmanAJ:perf/gpui-hotkey-mic-check
Draft

AatmanAJ wants to merge 1 commit into
CapSoftware:mainfrom
AatmanAJ:perf/gpui-hotkey-mic-check

Conversation

@AatmanAJ

Copy link
Copy Markdown
Contributor

Starting a recording from a hotkey with "Confirm before recording without a microphone" turned on (it's on by default) first checks that the selected microphone is still there. In the GPUI app that check was MicrophoneFeed::list().contains_key(name), which runs get_usable_device on every input device, and on the default device twice. The hotkey start waits on all of that before it does anything else.

On macOS, the Tauri confirm only matches the name (microphone_available_for_confirmation with MicrophoneFeed::list_names()). This PR does the same in GPUI. Other platforms keep list(), also as Tauri does.

Results

From the existing native_picker_latency benchmark (cargo test --bin cap-gpui native_picker_latency -- --ignored --nocapture), with 10 samples on an M5 Max running macOS 27 with 2 input devices:

Stage Median Max
microphone_metadata_all_devices (one MicrophoneFeed::list() per device, 2 calls) 280 ms 2,084 ms
tauri_device_inventory (list_cameras() plus MicrophoneFeed::list_names()) 0.32 ms 0.53 ms

So each list() call that this removes from the hotkey path was about 140 ms at the median, with a worst case around a second.

Tests

  • cargo test --bin cap-gpui hotkeys: 5 passed.
  • cargo clippy --bin cap-gpui reports the same 7 existing warnings as main, none in hotkeys.rs.

Not yet tested

The hotkey start with a microphone selected, and the "No microphone detected" sheet for a missing one, still need hand-testing.

Starting a recording from a hotkey with "confirm before recording
without a microphone" on (the default) first called
MicrophoneFeed::list(), which reads every input device's configuration.
The Tauri confirm only matches the device name on macOS
(microphone_available_for_confirmation); do the same here so the start
isn't held up by a CoreAudio config scan.

This branch has not been deployed

No deployments
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.

1 participant