Skip to content

fix(macos): prevent crash on launch when no microphone available#5656

Closed
sfo2001 wants to merge 1 commit intoopenclaw:mainfrom
sfo2001:fix/macos-no-microphone-crash
Closed

fix(macos): prevent crash on launch when no microphone available#5656
sfo2001 wants to merge 1 commit intoopenclaw:mainfrom
sfo2001:fix/macos-no-microphone-crash

Conversation

@sfo2001
Copy link
Contributor

@sfo2001 sfo2001 commented Jan 31, 2026

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 Overview

Greptile Summary

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.

Confidence Score: 4/5

  • 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

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

@openclaw-barnacle openclaw-barnacle bot added the app: macos App: macos label Jan 31, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@sfo2001 sfo2001 force-pushed the fix/macos-no-microphone-crash branch from 4f4407b to cc04084 Compare January 31, 2026 20:01
@suckerfish suckerfish mentioned this pull request Feb 1, 2026
@sfo2001 sfo2001 force-pushed the fix/macos-no-microphone-crash branch 2 times, most recently from 457dfd9 to 36928e3 Compare February 14, 2026 13:22
@sfo2001 sfo2001 force-pushed the fix/macos-no-microphone-crash branch 2 times, most recently from bbb8e4c to 524bbf8 Compare February 15, 2026 09:40
@sfo2001 sfo2001 force-pushed the fix/macos-no-microphone-crash branch 2 times, most recently from 126f41c to a9ed2da Compare February 21, 2026 13:06
Guard against missing audio input device before accessing
AVAudioEngine.inputNode. On Macs without built-in microphone
(e.g., Mac mini) with no external mic connected, accessing
inputNode can crash with SIGABRT.

Uses existing AudioInputDeviceObserver.defaultInputDeviceUID()
which already uses Core Audio APIs to check for input devices.

Fixes openclaw#5529

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sfo2001 sfo2001 force-pushed the fix/macos-no-microphone-crash branch from a9ed2da to c4135b2 Compare February 22, 2026 16:58
@steipete
Copy link
Contributor

Closing as AI-assisted stale-fix triage.

Linked issue #5529 ("[Bug]: macOS App crashes on launch when no audio input device is available") is currently closed and was closed on 2026-02-03T19:15:37Z with state reason completed.
Given that issue is closed, this fix PR is no longer needed in the active queue and is being closed as stale.

If this specific implementation is still needed on current main, please reopen #5656 (or open a new focused fix PR) and reference #5529 for fast re-triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS App crashes on launch when no audio input device is available

2 participants