Skip to content

Prevent audio-device changes from stalling dictation hotkeys#700

Draft
supfeer wants to merge 1 commit into
altic-dev:mainfrom
supfeer:agent/fix-audio-route-hotkey-stall
Draft

Prevent audio-device changes from stalling dictation hotkeys#700
supfeer wants to merge 1 commit into
altic-dev:mainfrom
supfeer:agent/fix-audio-route-hotkey-stall

Conversation

@supfeer

@supfeer supfeer commented Jul 23, 2026

Copy link
Copy Markdown

Description

Prevents audio-device topology changes from leaving dictation permanently unresponsive.

An AVAudioEngine can block during deallocation in Apple's hardware-format path. Retirement previously used a serial queue without a deadline, so later hotkey callbacks reached ASRService.start() but waited forever for the poisoned queue.

This PR:

  • bounds audio-engine retirement and barrier waits with a three-second watchdog
  • propagates retirement timeouts through compatibility startup and route recovery so start/stop state remains retryable
  • attempts direct Core Audio capture before waiting on an old AVAudioEngine retirement

Type of Change

  • 🐞 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 🧹 Chore
  • 📝 Documentation update

Related Issue or Discussion

Closes #682.

Testing

  • Tested on Intel Mac
  • Tested on Apple Silicon Mac
  • Tested on macOS version: 26.5.2
  • Ran linter locally: swiftlint --strict --config .swiftlint.yml Sources
  • Ran formatter locally: swiftformat --config .swiftformat Sources
  • Ran tests locally: xcodebuild test -project Fluid.xcodeproj -scheme Fluid -configuration Debug -destination 'platform=macOS' -derivedDataPath DerivedData DEVELOPMENT_TEAM=2GT974SA8P -only-testing:FluidDictationIntegrationTests/AudioEngineRetirementDrainTests -quiet

Additional checks:

  • swiftlint --strict --config .swiftlint.yml Sources passed with 0 violations in 136 files.
  • swiftformat --lint --config .swiftformat Sources was run without modifying files, but the repository-wide baseline failed because 60 of 136 existing files require formatting; no formatting changes are included in this focused bug-fix PR.
  • ./build.sh completed successfully with a signed Debug build.
  • git diff --cached --check passed before commit.
  • Field log inspection confirmed hotkey callbacks continued firing while retirement barriers timed out after a real soundcore Liberty 5 Pro route change.

Screenshots / Video

  • No UI/visual changes; screenshots/video are not applicable.

Notes

  • Direct Core Audio remains controlled by the existing Faster Recording Start setting; this PR does not change its default or persisted value.
  • AudioEngineRetirementDrainTests covers off-main release ordering and bounded timeout recovery.
  • Physical Bluetooth connect/disconnect remains a manual hardware regression scenario; the unit test does not claim to emulate a Bluetooth route.

@github-actions github-actions Bot added needs PR template Pull request is missing required template content. needs screenshots Pull request needs screenshot or video evidence. labels Jul 23, 2026
@github-actions

Copy link
Copy Markdown

The PR Policy check is blocking this PR because required template information is missing.

Please update the PR description with:

  • Description
  • Type of Change
  • Related Issue or Discussion
  • Testing
  • Screenshots / Video

Visual files detected:

  • Sources/Fluid/Persistence/SettingsStore.swift

Screenshots or video are required for UI, UX, settings, onboarding, overlay, menu bar, or visual behavior changes. If this PR has no visual changes, check the no-visual-change box in the template.

If this remains incomplete for 48 hours after opening, the PR may be closed.

@github-actions github-actions Bot removed needs PR template Pull request is missing required template content. needs screenshots Pull request needs screenshot or video evidence. labels Jul 23, 2026
@supfeer
supfeer force-pushed the agent/fix-audio-route-hotkey-stall branch from 4f17c56 to 9f7c367 Compare July 23, 2026 16:44
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.

Hang on audio-device change in 1.6.5 — AVAudioEngine start/stop stalls in _GetHWFormat (distinct from #665 crash)

1 participant