Skip to content

Fix recording stuck with BT headphones + auto-retry on timeout#4

Merged
idanyekutiel merged 2 commits intomainfrom
idanyekutiel/fix-recording-stuck
Mar 27, 2026
Merged

Fix recording stuck with BT headphones + auto-retry on timeout#4
idanyekutiel merged 2 commits intomainfrom
idanyekutiel/fix-recording-stuck

Conversation

@idanyekutiel
Copy link
Copy Markdown
Owner

@idanyekutiel idanyekutiel commented Mar 23, 2026

Summary

  • Fix recording permanently stuck on loading spinner when Bluetooth headphones (e.g. AirPods Max) are connected, even when using the built-in mic. The audio engine's config change handler ignored events during startup due to an isRecording race condition.
  • Add automatic single retry when Whisper API transcription times out, instead of immediately failing and requiring manual retry from settings.

Test plan

  • Record with AirPods Max connected but MacBook Pro mic selected
  • Connect AirPods Max while app is idle, then record
  • Record with no BT devices (regression check)
  • Simulate/wait for a transcription timeout — should retry automatically

When AirPods Max (or other BT devices) are connected, starting the audio
engine triggers a Bluetooth profile renegotiation that fires an
AVAudioEngineConfigurationChange notification, stopping the engine.

Two bugs caused the recording to get stuck permanently:

1. handleConfigChange() guarded on isRecording, which is set async on
   the main queue AFTER engine.start(). Config changes during startup
   were silently ignored, leaving the engine stopped with no recovery.

2. The tap callback guarded on isRecording, dropping all initial buffers
   before the main-queue flag was set. onRecordingReady never fired, so
   the overlay stayed on the spinner indefinitely.

Fix: replace the isRecording guard in handleConfigChange with an
audioEngine != nil check, adding a lightweight restart path for startup
config changes that re-asserts the target device and restarts the engine.
Remove the redundant isRecording guard from the tap callback since the
tap's lifetime already matches the recording lifecycle.
Whisper API calls occasionally time out on first attempt but succeed on
retry. Add a single automatic retry with a status message instead of
immediately failing and requiring manual retry from settings.
@idanyekutiel idanyekutiel changed the title Fix recording stuck on loading with Bluetooth headphones connected Fix recording stuck with BT headphones + auto-retry on timeout Mar 27, 2026
@idanyekutiel idanyekutiel merged commit d61da87 into main Mar 27, 2026
1 check passed
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