Repository navigation
Fix recorder teardown race, CFHash overflow trap, ignored mic pin - #370
Merged
Merged
Conversation
- SystemAudioRecorder.teardown() read MixWriter.summary on the caller's thread while the IOProc was still writing those counters on the recorder queue. Read it inside queue.sync, after the IOProc stops. - PressFingerprint converted CFHash (UInt) with Int(_:), which traps on any hash with the top bit set. Convert by bit pattern instead. - The Record button's recorder bound the system default input and ignored the microphone pinned in Settings. Resolve the pin first, falling back to the default when it isn't connected, as dictation does. Fixes #340 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1SoHzenCMeXaqWBW2k
heldReadStartsAfterTheDelay waited on the router's real 300 ms hold timer through waitUntil's 5 s budget. On a loaded CI run (every test in the suite taking ~7 s) the timer task was starved past that budget and the test failed with CancellationError, as on #370. Step it on a TestClock as its sibling test already does, and assert the hold is still 1 ms away rather than measuring a wall-time lower bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1SoHzenCMeXaqWBW2k
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
…eld-read test #375 gave the relay a ResultAddress presser; the injected clock now sits beside it, and the delivered test steps the clock while asserting the controller. #370 independently moved the held-read test onto a TestClock with its own press helper; its version is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Fixes #340 — three bugs in the Record button's recorder and voice commands — plus a flaky test this PR's CI surfaced.
1. Data race in
SystemAudioRecorder.teardown(). The "recorder stopping" log readMixWriter.summaryon the caller's thread before the IOProc was stopped, while the IOProc was still writing those counters (and thelastErrorstring) on the recorder's queue. The summary is now read inside the existingqueue.sync, afterAudioDeviceStop/AudioDeviceDestroyIOProcID, just before the file closes.2. Overflow trap on
CFHash.PressFingerprint.focusedElementconverted the unsignedCFHashCodewithInt(_:), which traps whenever the top bit is set — on anypressin Chromium/Electron orselectin any app. It now usesInt(bitPattern:); only equality is ever asked of the value, so the type staysInt?.3. Recorder ignored the pinned microphone. The recorder always bound the system default input, ignoring the microphone pinned in Settings › Microphone. It now resolves the pin first and falls back to the system default when the pinned device isn't connected, the same rule dictation follows. Doc comments in
SystemAudioRecorderandMicDeviceStoreupdated to match.Flaky test.
SelectionSpeechRouterLifecycleTests"a held read starts once the key has been down for the hold delay" waited on the real 300 ms hold timer withinwaitUntil's 5 s budget; on a loaded CI run (every test taking ~7 s) the timer task was starved and it failed withCancellationError(unrelated to the changes above). It now steps the router's injected clock withTestClock, as its sibling test already did, asserting the hold is still 1 ms away before advancing the last millisecond. The shared press-wait-advance steps moved into a helper to satisfy jscpd.How it was tested
scripts/check.shpasses (or CI will, if I'm not on a Mac)Written in a Linux sandbox:
scripts/check.sh --portablepasses locally; CI on macOS (fullcheck, iOS build and sanitizers) is green on the head commit. No new tests for fixes 1–3: they live in Core Audio / Accessibility glue that the unit tests don't drive.🤖 Generated with Claude Code
https://claude.ai/code/session_01DS5B1SoHzenCMeXaqWBW2k