#5656: fix(macos): prevent crash on launch when no microphone available
app: macos
size: XS
trusted-contributor
Cluster:
Voice Transcription Enhancements
## Summary
Prevents macOS app crash on launch when no audio input device is available (e.g., Mac mini without external microphone).
Fixes #5529
## Root Cause
On macOS, accessing `AVAudioEngine.inputNode` when no audio input device exists triggers a SIGABRT crash instead of failing gracefully. The existing guard for `format.channelCount > 0` (line 171) is never reached because the crash occurs earlier when accessing `inputNode`.
## Fix
Added a guard checking `AVCaptureDevice.default(for: .audio) != nil` before accessing `inputNode`. This pattern is already used elsewhere in the codebase (`CameraCaptureService.swift:149`).
## Test plan
**Requires hardware testing** - I don't have access to a Mac without built-in microphone.
To test:
1. Use a Mac mini (or similar) with no external microphone connected
2. Launch OpenClaw.app
3. Verify app launches without crashing
4. Verify voice wake feature shows appropriate "no microphone" state instead of crashing
**With microphone connected:**
1. Connect an external microphone
2. Launch OpenClaw.app
3. Verify voice wake works normally
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds an early guard in `VoiceWakeRuntime.start(with:)` to avoid a macOS crash when accessing `AVAudioEngine.inputNode` on machines with no audio input device (e.g., Mac mini without an external mic). The change checks for the presence of an audio capture device before touching `inputNode`, and throws a descriptive error that gets logged and causes the voice-wake runtime to stop cleanly.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge and should prevent the reported crash, with some caveats around how reliably the new guard reflects audio-input availability.
- The change is small and localized, and it adds an early-exit before the known-crashing access. Main concern is that `AVCaptureDevice.default(for: .audio)` may not precisely match the conditions under which `AVAudioEngine.inputNode` crashes, so it may not cover all edge cases (permissions/routing).
- apps/macos/Sources/OpenClaw/VoiceWakeRuntime.swift
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#18235: macOS: prevent Voice Wake crash when no input device is available
by agisilaos · 2026-02-16
86.7%
#14458: fix(voicewake): avoid crash on foreign transcript ranges
by guchang · 2026-02-12
72.6%
#9926: fix(macos): guard UNUserNotificationCenter when no bundle identifier
by webcpu · 2026-02-05
70.5%
#9703: feat(macos): Voice settings restructure + Whisper transcription sup...
by nsd97 · 2026-02-05
68.9%
#15909: Guard notifications on macOS; fix focus issue and build fixes
by jasonkneen · 2026-02-14
68.7%
#3337: fix(macos-app): patch SwiftPM Bundle.module accessor for app bundle
by skymoore · 2026-01-28
67.4%
#15914: feat: add messages.suppressMediaPlaceholders config option
by Shuai-DaiDai · 2026-02-14
66.3%
#10182: fix: skip non-openclaw LaunchAgents in doctor gateway scan
by Yida-Dev · 2026-02-06
66.3%
#18792: docs: add macOS source-run troubleshooting for setup/auth issues
by yash27-lab · 2026-02-17
65.8%
#12191: fix: guard against undefined model.input in display and scan layers
by mcaxtr · 2026-02-09
65.6%