Webrtc Swift - 线程 1:EXC_BAD_ACCESS(代码=1,地址=0xd000000000000040)

Webrtc Swift - Thread 1: EXC_BAD_ACCESS (code=1, address=0xd000000000000040)

我正在使用 Janus videoroom 和 Webrtc。一切正常。但是当我结束通话时。并关闭当前视图控制器 - App Crashed。

我无法得到崩溃的点,所以我可以解决。

当前视图也消失了。日志显示:

callDropButton Clicked
Videoroom viewDidDisappear
Videoroom screen dismissed completely

我在 Appdelegate 的第一行遇到崩溃:

class AppDelegate: UIResponder, UIApplicationDelegate {

我还附上了回溯日志以获取更多信息。但这对我来说没有任何意义:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xd000000000000040)
frame #0: 0x00000001012e0024 WebRTC`___lldb_unnamed_symbol6199$$WebRTC + 120
frame #1: 0x00000001013c70f0 WebRTC`___lldb_unnamed_symbol12553$$WebRTC + 44
frame #2: 0x00000001013c7078 WebRTC`___lldb_unnamed_symbol12551$$WebRTC + 128
frame #3: 0x00000001013c6964 WebRTC`___lldb_unnamed_symbol12523$$WebRTC + 12
frame #4: 0x00000001013c6944 WebRTC`___lldb_unnamed_symbol12521$$WebRTC + 52
frame #5: 0x00000001012e16b0 WebRTC`___lldb_unnamed_symbol6278$$WebRTC + 36
frame #6: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #7: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #8: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #9: 0x00000001012f343c WebRTC`___lldb_unnamed_symbol6908$$WebRTC + 328
frame #10: 0x000000010050c8b0 Interpret`outlined destroy of RTCVideoTrack? at <compiler-generated>:0
frame #11: 0x00000001005346ec Interpret`@objc ConnectionViewController.__ivar_destroyer(self=0x0000000154016800) at ConnectionViewController.swift:0
frame #12: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #13: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #14: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #15: 0x00000001d04a5de8 UIKitCore`-[UIResponder dealloc] + 152
frame #16: 0x00000001cfeced0c UIKitCore`-[UIViewController dealloc] + 1748
frame #17: 0x00000001cfe07594 UIKitCore`-[UIPresentationController .cxx_destruct] + 372
frame #18: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #19: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #20: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #21: 0x00000001cfe030fc UIKitCore`-[UIPresentationController dealloc] + 60
frame #22: 0x00000001cfe08d5c UIKitCore`-[_UIFullscreenPresentationController dealloc] + 60
frame #23: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152
frame #24: 0x00000001cfefbaf8 UIKitCore`-[_UIViewControllerTransitionContext .cxx_destruct] + 116
frame #25: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #26: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #27: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #28: 0x00000001cfefa3f8 UIKitCore`-[_UIViewControllerTransitionContext dealloc] + 60
frame #29: 0x00000001cfefbbb0 UIKitCore`-[_UIViewControllerOneToOneTransitionContext dealloc] + 84
frame #30: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
frame #31: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68
frame #32: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16
frame #33: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152
frame #34: 0x00000001a444ca38 CoreFoundation`-[__NSSingleObjectArrayI dealloc] + 44
frame #35: 0x00000001d04870e8 UIKitCore`_runAfterCACommitDeferredBlocks + 356
frame #36: 0x00000001d0475bfc UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 352
frame #37: 0x00000001d04a2a6c UIKitCore`_afterCACommitHandler + 116
frame #38: 0x00000001a44ef4fc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #39: 0x00000001a44ea224 CoreFoundation`__CFRunLoopDoObservers + 412
frame #40: 0x00000001a44ea7a0 CoreFoundation`__CFRunLoopRun + 1228
frame #41: 0x00000001a44e9fb4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #42: 0x00000001a66eb79c GraphicsServices`GSEventRunModal + 104
frame #43: 0x00000001d047bc38 UIKitCore`UIApplicationMain + 212
* frame #44: 0x0000000100522d7c Interpret`main at AppDelegate.swift:13:7
frame #45: 0x00000001a3fad8e0 libdyld.dylib`start + 4

确保您的 deinit 中有这样的内容(“屏幕完全关闭”?):

rtcAudioSession.remove(self)
peerConnection.close()
[localAudioTrack,
 localVideoTrack,
 remoteAudioTrack,
 remoteVideoTrack,
].forEach { track in
    track.isEnabled = false
}

检查你创建的每个 WebRTC 对象,如果 class 有类似 close()isEnabled = false 等的东西,你应该在 deinit 中调用它。

根据您的崩溃日志,问题出在 RTCVideoTrack 个对象中。尝试注释掉创建任何 RTCVideoTrack 的所有代码,看看是否有帮助。如果有帮助,请将它们一一取消注释以确定是哪一个导致了问题。