stasel / WebRTC-iOS

A simple native WebRTC demo iOS app using swift
Apache License 2.0
1.11k stars 241 forks source link

Unknown crash only when kRTCMediaConstraintsOfferToReceiveAudio set to true #137

Closed dhavalyq closed 1 year ago

dhavalyq commented 1 year ago

If kRTCMediaConstraintsOfferToReceiveAudio set to true, app is getting crashed on setRemoteDescription only if the stream has audio other wise it's working fine.

let sessionDescription = RTCSessionDescription(type: .answer, sdp: sdp)

        // Set the remote session description
        self.peerConnection?.setRemoteDescription(sessionDescription) { (error) in
            guard error == nil else {
                print("Error: ",error.debugDescription)
                return
            }

            // Connection established, ready to start exchanging media
        }

Getting crash like this:

libsystem_kernel.dylib`:
    0x1baf94644 <+0>:  mov    x16, #0x209
    0x1baf94648 <+4>:  svc    #0x80
->  0x1baf9464c <+8>:  b.lo   0x1baf94668               ; <+36>
    0x1baf94650 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1baf94654 <+16>: mov    x29, sp
    0x1baf94658 <+20>: bl     0x1baf6b60c               ; cerror_nocancel
    0x1baf9465c <+24>: mov    sp, x29
    0x1baf94660 <+28>: ldp    x29, x30, [sp], #0x10
    0x1baf94664 <+32>: ret    
    0x1baf94668 <+36>: ret    
stanbohonos commented 6 days ago

I have the same issue. Is that already fixed?

dhavalyq commented 5 days ago

Yes, I figure out that when you set the kRTCMediaConstraintsOfferToReceiveAudio constraint to true in WebRTC, you must have to set Microphone Usage Description in info.plist file even if you're receiving only audio stream.

stanbohonos commented 3 days ago

Yeah, thanks for the reply. I guessed the same thing myself.

NSMicrophoneUsageDescription

I didn't see that error in the console because I always used the filter for WebRTC. I couldn't even think of needing mic rights to play audio, but from a WebRTC perspective, it makes sense.