From b46855d8c4f1d043134bf98afebe00d0ece554d5 Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Tue, 20 Jan 2026 20:52:42 -0800 Subject: [PATCH] fix(ios): prevent Talk mode crash on simulator - Disable Talk mode start on iOS simulator (no audio input) - Validate audio input format before installing tap to avoid AVFAudio assertion crashes on misconfigured devices. Tested: - Launched app on iOS simulator and tapping Talk no longer crashes (shows error path instead). --- apps/ios/Sources/Voice/TalkModeManager.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/ios/Sources/Voice/TalkModeManager.swift b/apps/ios/Sources/Voice/TalkModeManager.swift index 082ed3d89..16ae245eb 100644 --- a/apps/ios/Sources/Voice/TalkModeManager.swift +++ b/apps/ios/Sources/Voice/TalkModeManager.swift @@ -132,6 +132,12 @@ final class TalkModeManager: NSObject { } private func startRecognition() throws { + #if targetEnvironment(simulator) + throw NSError(domain: "TalkMode", code: 2, userInfo: [ + NSLocalizedDescriptionKey: "Talk mode is not supported on the iOS simulator", + ]) + #endif + self.stopRecognition() self.speechRecognizer = SFSpeechRecognizer() guard let recognizer = self.speechRecognizer else { @@ -146,6 +152,11 @@ final class TalkModeManager: NSObject { let input = self.audioEngine.inputNode let format = input.outputFormat(forBus: 0) + guard format.sampleRate > 0, format.channelCount > 0 else { + throw NSError(domain: "TalkMode", code: 3, userInfo: [ + NSLocalizedDescriptionKey: "Invalid audio input format", + ]) + } input.removeTap(onBus: 0) let tapBlock = Self.makeAudioTapAppendCallback(request: request) input.installTap(onBus: 0, bufferSize: 2048, format: format, block: tapBlock)