Getting crash when ice candidate delegate method called

在这里输入图像描述 Please help what is the issue.???

webrtc library calling some internal method and getting excess_bad. and crashed

If needed any more information plz ask.

//code

 let iceServer = RTCICEServer(uri:URL(string: resturi), username: “***”, password: “***”)

// Enable SSL globally for WebRTC in our app
let pcFactory:RTCPeerConnectionFactory = RTCPeerConnectionFactory()

let rtcConfiguration = RTCConfiguration()
rtcConfiguration.iceServers = [iceServer!]

let pair1 = RTCPair(key: "OfferToReceiveAudio", value: "true")
let pair2 = RTCPair(key: "OfferToReceiveVideo", value: "false")

let pair3 = RTCPair(key: "DtlsSrtpKeyAgreement", value: "true")

self.mediaConstraints = RTCMediaConstraints(mandatoryConstraints: [pair1!,pair2!], optionalConstraints:[pair3!])

 // Create the peer connection using the ICE server list and the current class as the delegate

    let localStream:RTCMediaStream = pcFactory.mediaStream(withLabel: “12345”)
    let audioTrack:RTCAudioTrack = pcFactory.audioTrack(withID: “123456”)
    audioTrack.delegate = self

    let status = localStream.addAudioTrack(audioTrack)

 self.peerConnection = pcFactory.peerConnection(with: rtcConfiguration, constraints: self.mediaConstraints!, delegate: self)

  let pstatus = self.peerConnection!.add(localStream)

  print(status)
  print(pstatus)

//Let’s look at how the offer is created, which initiates the call.
 self.peerConnection!.createOffer(with: self, constraints: self.mediaConstraints)

I am getting sip here.

public func peerConnection(_ peerConnection: RTCPeerConnection!, didCreateSessionDescription sdp: RTCSessionDescription!, error: Error!)

getting crash when this delegate called.

func peerConnection(_ peerConnection: RTCPeerConnection!, gotICECandidate candidate: RTCICECandidate!)

Crash Report

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x5000000000000038 Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [0] Triggered by Thread: 9

Filtered syslog: None found

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0: 0
libsystem_kernel.dylib 0x000000018f58816c mach_msg_trap + 8 1 libsystem_kernel.dylib 0x000000018f587fdc mach_msg + 72 2
CoreFoundation 0x0000000190585cec __CFRunLoopServiceMachPort + 192 3 CoreFoundation 0x0000000190583908 __CFRunLoopRun + 1132 4 CoreFoundation
0x00000001904b2048 CFRunLoopRunSpecific + 444 5 GraphicsServices
0x0000000191f35198 GSEventRunModal + 180 6 UIKit
0x000000019648b818 -[UIApplication _run] + 684 7 UIKit
0x0000000196486550 UIApplicationMain + 208 8 Shukran
0x0000000100080a1c 0x10007c000 + 18972 9 libdyld.dylib
0x000000018f4945b8 start + 4

Thread 1 name: com.apple.uikit.eventfetch-thread Thread 1: 0
libsystem_kernel.dylib 0x000000018f58816c mach_msg_trap + 8 1 libsystem_kernel.dylib 0x000000018f587fdc mach_msg + 72 2
CoreFoundation 0x0000000190585cec CFRunLoopServiceMachPort + 192 3 CoreFoundation 0x0000000190583908 __CFRunLoopRun + 1132 4 CoreFoundation
0x00000001904b2048 CFRunLoopRunSpecific + 444 5 Foundation
0x0000000190fc0b1c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304 6 Foundation 0x0000000190fe160c -[NSRunLoop(NSRunLoop) runUntilDate:] + 96 7 UIKit 0x0000000196e00e6c -[UIEventFetcher threadMain] + 136 8 Foundation 0x00000001910be50c __NSThread__start + 1024 9
libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 10 libsystem_pthread.dylib 0x000000018f66b770 _pthread_body + 0 11 libsystem_pthread.dylib 0x000000018f668dbc thread_start + 4

Thread 2 name: AVAudioSession Notify Thread Thread 2: 0
libsystem_kernel.dylib 0x000000018f58816c mach_msg_trap + 8 1 libsystem_kernel.dylib 0x000000018f587fdc mach_msg + 72 2
CoreFoundation 0x0000000190585cec __CFRunLoopServiceMachPort + 192 3 CoreFoundation 0x0000000190583908 __CFRunLoopRun + 1132 4 CoreFoundation
0x00000001904b2048 CFRunLoopRunSpecific + 444 5 AVFAudio
0x00000001a9baafe8 GenericRunLoopThread::Entry(void*) + 164 6
AVFAudio 0x00000001a9bd0f14 CAPThread::Entry(CAPThread*) + 84 7 libsystem_pthread.dylib
0x000000018f66b860 _pthread_body + 240 8 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 9 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 3 name: com.apple.NSURLConnectionLoader Thread 3: 0
libsystem_kernel.dylib 0x000000018f58816c mach_msg_trap + 8 1 libsystem_kernel.dylib 0x000000018f587fdc mach_msg + 72 2
CoreFoundation 0x0000000190585cec CFRunLoopServiceMachPort + 192 3 CoreFoundation 0x0000000190583908 __CFRunLoopRun + 1132 4 CoreFoundation
0x00000001904b2048 CFRunLoopRunSpecific + 444 5 CFNetwork
0x0000000190c9fcec +[NSURLConnection(Loader) _resourceLoadLoop:] + 336 6 Foundation 0x00000001910be50c __NSThread__start + 1024 7 libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 8 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 9 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 4: 0 libsystem_pthread.dylib 0x000000018f668db0 start_wqthread + 0

Thread 5: 0 libsystem_kernel.dylib 0x000000018f5a6a88 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x000000018f669188 _pthread_wqthread + 968 2
libsystem_pthread.dylib 0x000000018f668db4 start_wqthread + 4

Thread 6: 0 libsystem_pthread.dylib 0x000000018f668db0 start_wqthread + 0

Thread 7: 0 libsystem_kernel.dylib 0x000000018f5a5e1c __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x000000018f66a9d0 _pthread_cond_wait + 640 2 Shukran
0x000000010030009c 0x10007c000 + 2637980 3 libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 4 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 5 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 8: 0 libsystem_kernel.dylib 0x000000018f5a623c __select + 8 1 Shukran 0x00000001003004d0 0x10007c000 + 2639056 2 libsystem_pthread.dylib
0x000000018f66b860 _pthread_body + 240 3 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 4 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 9 name: VoiceProcessThread Thread 9 Crashed: 0 Shukran
0x00000001001956ac 0x10007c000 + 1152684 1 Shukran
0x000000010019569c 0x10007c000 + 1152668 2 Shukran
0x0000000100168688 0x10007c000 + 968328 3 Shukran
0x0000000100191020 0x10007c000 + 1134624 4 Shukran
0x000000010033b1bc 0x10007c000 + 2879932 5 Shukran
0x00000001002d906c 0x10007c000 + 2478188 6 Shukran
0x00000001002d8670 0x10007c000 + 2475632 7 Shukran
0x00000001002ca330 0x10007c000 + 2417456 8 Shukran
0x00000001004293f0 0x10007c000 + 3855344 9 Shukran
0x00000001002fb010 0x10007c000 + 2617360 10 Shukran
0x00000001002faf94 0x10007c000 + 2617236 11 libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 12 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 13 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 10 name: PacerThread Thread 10: 0 libsystem_kernel.dylib
0x000000018f5a5e1c __psynch_cvwait + 8 1 libsystem_pthread.dylib
0x000000018f66a9d0 _pthread_cond_wait + 640 2 Shukran
0x000000010028548c 0x10007c000 + 2135180 3 Shukran
0x00000001002f7544 0x10007c000 + 2602308 4 Shukran
0x00000001004294f0 0x10007c000 + 3855600 5 Shukran
0x00000001002fb010 0x10007c000 + 2617360 6 Shukran
0x00000001002faf94 0x10007c000 + 2617236 7 libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 8 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 9 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 11 name: ModuleProcessThread Thread 11: 0
libsystem_kernel.dylib 0x000000018f5a5e1c __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x000000018f66a9d0 _pthread_cond_wait + 640 2 Shukran 0x000000010028548c 0x10007c000 + 2135180 3 Shukran
0x00000001002f7544 0x10007c000 + 2602308 4 Shukran
0x00000001004294f0 0x10007c000 + 3855600 5 Shukran
0x00000001002fb010 0x10007c000 + 2617360 6 Shukran
0x00000001002faf94 0x10007c000 + 2617236 7 libsystem_pthread.dylib 0x000000018f66b860 _pthread_body + 240 8 libsystem_pthread.dylib
0x000000018f66b770 _pthread_body + 0 9 libsystem_pthread.dylib
0x000000018f668dbc thread_start + 4

Thread 9 crashed with ARM Thread State (64-bit): x0: 0x000000010303c100 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x00000001024694e8 x4: 0x0000000000000000 x5: 0x0000000000000010 x6: 0x0000000000000002 x7: 0x000000016e54a45c x8: 0x5000000000000000 x9: 0x0000000000000000 x10: 0x000000016e54b818 x11: 0x0000000000000000 x12: 0x03e0fe0003e0fe00 x13: 0x000000018f66b770 x14: 0x000000018f668dbc x15: 0x0000000000000010 x16: 0x000000018f669ab8 x17: 0x0000000000000001 x18: 0x0000000000000000 x19: 0x0000000000000004 x20: 0x0000000104082e00 x21: 0x00000001702a42c0 x22: 0x000000016e54a278 x23: 0x00000001702a42e8 x24: 0x000000016e54a240 x25: 0x00000001702a42c8 x26: 0x00000001702a42e0 x27: 0xd96031967698005a
x28: 0x0000000000000000 fp: 0x000000016e54a1f0 lr: 0x000000010019569c sp: 0x000000016e549b10 pc: 0x00000001001956ac cpsr: 0x60000000


Please check your iceServer is Running fine or not, I have used Following iceServers and resolved the crash. Or you can build your own STUN server . It may be one of reason you are getting the crash.

let iceServer1:RTCICEServer = RTCICEServer.init(uri: URL.init(string: "stun:stun.l.google.com:19302"), username: "", password: "")

OR

let iceServer2:RTCICEServer = RTCICEServer.init(uri: URL.init(string: "turn:numb.viagenie.ca"), username: "webrtc@live.com", password: "muazkh")
链接地址: http://www.djcxy.com/p/93628.html

上一篇: IOS设备日志

下一篇: 冰候选人委托方法调用时发生崩溃