Skip to content

Fix audio crash with AirPods Max and multi-channel devices#3

Merged
idanyekutiel merged 1 commit intomainfrom
idanyekutiel/airpods-audio-crash
Mar 23, 2026
Merged

Fix audio crash with AirPods Max and multi-channel devices#3
idanyekutiel merged 1 commit intomainfrom
idanyekutiel/airpods-audio-crash

Conversation

@idanyekutiel
Copy link
Copy Markdown
Owner

Summary

  • Mono tap format: Always request mono format for the AVAudioEngine tap instead of using the device's native format. Multi-channel devices (AirPods Max, Studio Display 3-mic array) deliver multi-channel buffers that crash when written to a mono output file.
  • Full engine rebuild on config change: Replace the old patch-up recovery (remove tap → reinstall → restart) with a complete teardown + rebuild. The old approach caused an uncatchable ObjC NSException in installTapOnBus ("required condition is false: !_tapNode"), resulting in SIGABRT.
  • Unconditional tap removal: removeTap() no longer guards on the tapInstalled flag, which could get out of sync after config changes. removeTap(onBus:) is a safe no-op when no tap exists.

Test plan

  • Record with AirPods Max connected — should not crash
  • Record with Studio Display mic — should not crash
  • Record with MacBook Pro mic while AirPods Max connected — should not crash
  • Switch audio devices mid-recording — should recover gracefully
  • Verify audio quality is clean mono, not garbled/muffled

Three fixes for crashes triggered by Bluetooth/external audio devices:

1. Always request mono format for the tap — multi-channel devices
   (AirPods Max, Studio Display) deliver multi-channel buffers that
   crash when written to a mono output file.

2. Full engine teardown + rebuild on config change instead of trying
   to patch up a partially-reset engine. The old approach caused an
   ObjC NSException in installTapOnBus that Swift cannot catch.

3. Make removeTap() unconditional — the tapInstalled flag could get
   out of sync after config changes, leaving a stale tap that blocks
   reinstallation.
@idanyekutiel idanyekutiel merged commit 507ccaf into main Mar 23, 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