objective-c - AVAudioEngine 在 iOS14 中获取 inputNode 属性崩溃

标签 objective-c ios14

这是一个启动audioEngine的函数。

- (void)startAudioEngine {
    NSError *error = nil;
    if (!self.audioEngine.isRunning) {
        self.audioEngine = [[AVAudioEngine alloc] init];
        AVAudioInputNode *inputNode = self.audioEngine.inputNode;
        AVAudioFormat *nativeAudioFormat = [inputNode inputFormatForBus:0];
        __weak typeof(self)weakSelf = self;
        [inputNode installTapOnBus:0 bufferSize:1024 format:nativeAudioFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
            [weakSelf.recognitionRequest appendAudioPCMBuffer:buffer];
        }];
        [self.audioEngine prepare];
        [self.audioEngine startAndReturnError:&error];
        if (error) {
            [self stop];
            [self onError:[NSError errorWithDomain:@"startAudioEngine error" code:0 userInfo:nil]];
        }
        else {
            [self activeStatusChanged:MMSpeechRecognizerActiveStatusStared];
        }
    }
    else {
        [self stop];
        [NSError errorWithDomain:@"The audio engine is runing" code:0 userInfo:nil];
    }
}

在 iOS 14 中 self.audioEngine.inputNode 行崩溃。

以下是一些错误日志:

[plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000032144c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
HALB_IOBufferManager_Client::GetIOBuffer: the stream index is out of range
HALB_IOBufferManager_Client::GetIOBuffer: the stream index is out of range
[aqme] 255: AQDefaultDevice (1): output stream 0: null buffer
[aqme] 1778: EXCEPTION thrown (-50): error != 0
 Initialize: Mach message timeout. Apparently deadlocked. Aborting now.
CoreSimulator 725.10 - Device: iPhone 11 (003A9CF3-FDD7-4C44-8607-CAB3FDBB904B) - Runtime: iOS 14.0 (18A5301v) - DeviceType: iPhone 11

控制台中的 PO bt 显示如下:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  frame #0: 0x00007fff215a233a libsystem_kernel.dylib`pthread_kill + 10
  frame #1: 0x00007fff215d7e60 libsystem_pthread.dylib`pthread_kill + 430
  frame #2: 0x00007fff200c7c24 libsystem_c.dylib`abort + 120
  frame #3: 0x00000001082ce5c9 AudioToolboxCore`_ReportRPCTimeout(char const*, int) + 90
  frame #4: 0x0000000130cffbd9 libEmbeddedSystemAUs.dylib`_CheckRPCError(char const*, int, int) + 92
  frame #5: 0x0000000130cfc4e0 libEmbeddedSystemAUs.dylib`AURemoteIO::Initialize() + 1878
  frame #6: 0x0000000130d15ec6 libEmbeddedSystemAUs.dylib`AUBase::DoInitialize() + 36
  frame #7: 0x0000000130c9c47f libEmbeddedSystemAUs.dylib`AUMethodInitialize(void*) + 59
  frame #8: 0x00000001083c31bb AudioToolboxCore`-[AUAudioUnitV2Bridge allocateRenderResourcesAndReturnError:] + 77
  frame #9: 0x0000000105aa0dbf AVFAudio`AUInterfaceBaseV3::Initialize() + 45
  frame #10: 0x0000000105a8b90f AVFAudio`AVAudioIONodeImpl::GetInputFormat(unsigned long) + 125
  frame #11: 0x0000000105a8b5d3 AVFAudio`AVAudioIONodeImpl::SetOutputFormat(unsigned long, AVAudioFormat*) + 571
  frame #12: 0x0000000105a86022 AVFAudio`-[AVAudioNode setOutputFormat:forBus:] + 70
  frame #13: 0x0000000105a9d1e3 AVFAudio`AVAudioEngineImpl::UpdateInputNode(bool) + 921
  frame #14: 0x0000000105a98fd8 AVFAudio`-[AVAudioEngine inputNode] + 88
 * frame #15: 0x0000000102c64391 iOS14Demo`-[MMSpeechRecognizer startAudioEngine](self=0x0000600002777c40, _cmd="startAudioEngine") at MMSpeechRecognizer.m:72:56
  frame #16: 0x0000000102c651fd iOS14Demo`-[MMSpeechRecognizer start](self=0x0000600002777c40, _cmd="start") at MMSpeechRecognizer.m:175:13
  frame #17: 0x0000000102c63929 iOS14Demo`-[ViewController siriBtnClick:](self=0x00007f8dda60b650, _cmd="siriBtnClick:", sender=0x00007f8ddb80b3a0) at ViewController.m:66:9
  frame #18: 0x0000000114403f15 UIKitCore`-[UIApplication sendAction:to:from:forEvent:] + 83
  frame #19: 0x0000000113d5da2a UIKitCore`-[UIControl sendAction:to:forEvent:] + 223
  frame #20: 0x0000000113d5dd4d UIKitCore`-[UIControl _sendActionsForEvents:withEvent:] + 332
  frame #21: 0x0000000113d5c636 UIKitCore`-[UIControl touchesEnded:withEvent:] + 500
  frame #22: 0x000000011443f389 UIKitCore`-[UIWindow _sendTouchesForEvent:] + 1287
  frame #23: 0x00000001144411ea UIKitCore`-[UIWindow sendEvent:] + 4750
  frame #24: 0x000000011441b39d UIKitCore`-[UIApplication sendEvent:] + 428
  frame #25: 0x00000001144aabb1 UIKitCore`processEventQueue + 14793
  frame #26: 0x00000001144a175f UIKitCore`eventFetcherSourceCallback + 106
  frame #27: 0x00000001034f18bc CoreFoundation`CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
  frame #28: 0x00000001034f17fb CoreFoundation`CFRunLoopDoSource0 + 157
  frame #29: 0x00000001034f0f3f CoreFoundation`CFRunLoopDoSources0 + 222
  frame #30: 0x00000001034eba20 CoreFoundation`CFRunLoopRun + 882
  frame #31: 0x00000001034eb2fa CoreFoundation`CFRunLoopRunSpecific + 538
  frame #32: 0x00000001081ebdb3 GraphicsServices`GSEventRunModal + 139
  frame #33: 0x00000001143fd942 UIKitCore`-[UIApplication _run] + 912
  frame #34: 0x0000000114402f62 UIKitCore`UIApplicationMain + 1570
  frame #35: 0x0000000102c660ca iOS14Demo`main(argc=1, argv=0x00007ffeecf9bc80) at main.m:17:12
  frame #36: 0x00007fff20222941 libdyld.dylib`start + 1
(lldb) 

iOS14。 Xcode12-beta。

在 self.audioEngine.inputNode 行崩溃。 iOS14 崩溃。 iOS14之前不会崩溃。

为什么? iOS14系统API的bug?

最佳答案

这是 Apple 的 iOS 系统错误。

Apple 已解决该问题。 出现在版本 12.0 beta (12A6159) 中。 Apple 在版本 12.0 beta 2 (12A6163b) 中已解决。

下一步:更新 Xcode 并再次测试。

谢谢。

关于objective-c - AVAudioEngine 在 iOS14 中获取 inputNode 属性崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62587118/

相关文章:

objective-c - 将 char 附加到现有字符串 Objective - C

objective-c - iPhone App通过LinkedIn API授权后无法确认

react-native - React Native 应用程序不向 iOS 14.5 用户发送事件

ios - SwiftUI map 显示注释

ios - 如何在 iOS 14、SwiftUI 2 中以编程方式更改 PageTabView?

swiftui - 如何将@namespace 传递给 SwiftUI 中的多个 View ?

iphone - UIAlertView 的子类被解除后运行方法

iphone - 检测哪个图像在 ScrollView 上

objective-c - 如何防止一行 UITableView 取消选择?

ios - SKAdNetwork-生成签名-如何确定使用哪个版本?