gpt4 book ai didi

ios - Google 附近的消息崩溃了 : AudioRecorderCallbackQueue on deallocation

转载 作者:行者123 更新时间:2023-11-30 12:51:25 25 4
gpt4 key购买 nike

我正在使用 Swift 来使用 Google 附近消息库。我按照示例代码设置了库。我使用蓝牙和麦克风来测试该功能。我在 viewDidDisappear() 中解除分配发布/订阅。基本上就是两行代码:

publication = nil
subscription = nil

但是,当我关闭 View Controller 时,有时整个应用程序会崩溃。堆栈跟踪仅显示崩溃与音频有关。这是堆栈跟踪的一部分:

Crashed: AudioRecorderCallbackQueue
0 libdispatch.dylib 0x18df39f60 _dispatch_barrier_sync_f_slow + 596

1 ProjectLibs 0x1037ad8e0 std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >::vector(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) + 2808

2 ProjectLibs 0x1037ad8e0 std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >::vector(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) + 2808

3 ProjectLibs 0x1037ad0f4 std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >::vector(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) + 780

4 libsystem_blocks.dylib 0x18df7ea28 _Block_release + 144

有谁知道可能导致崩溃的原因,以及如何解决它或防止应用程序崩溃?

谢谢!

最佳答案

我设置了一个应用程序,使其按照您所描述的方式运行。通过启用日志记录,我注意到它仍在短时间内发送消息,这很可能是您崩溃的原因。

您可以使用以下命令启用日志记录:

GNSMessageManager.setDebugLoggingEnabled(true)

通过在此过程的早期将它们设置为 nil,我能够在 View Controller 完全关闭之前停止发送它们。

以下内容会尽快执行(甚至在 viewWillDisappear 之前):

override func willMove(toParentViewController parent: UIViewController?) {
super.willMove(toParentViewController: parent)

if parent == nil {
publication = nil
subscription = nil
}
}

关于ios - Google 附近的消息崩溃了 : AudioRecorderCallbackQueue on deallocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com