cordova-plugin-iosrtc: onaddtrack crash during call initializing

Versions affected

  • Cordova version (e.g 7.1.0): 9
  • Plugin version (e.g 6.0.12): 6.0.12
  • iOS version (e.g 10.2): 12.x
  • Xcode version (e.g 11.1 - 11A1027): 11.5
  • WebRTC-adapter version (e.g. 7.4.0):
  • WebRTC Framework version (e.g. JSSip 3.1.2): sip.js v0.15.10

Description

During the call initializing i get error in swift code

2020-06-29 09:36:44.164862+0200 [421:17347] iosrtcPlugin#RTCPeerConnection_addIceCandidate()
2020-06-29 09:36:44.151683+0200 [421:17598] PluginRTCPeerConnection | onnegotiationeeded
2020-06-29 09:36:44.180578+0200 [421:17347] iosrtc:RTCPeerConnection onEvent() | [type:negotiationneeded, data:{"type":"negotiationneeded"}] +121ms
2020-06-29 09:36:44.181676+0200 [421:18696] PluginRTCPeerConnection#addTrack()
2020-06-29 09:36:44.182921+0200 [421:18696] PluginRTCPeerConnection#setRemoteDescription()
2020-06-29 09:36:44.199512+0200 [421:17598] PluginRTCPeerConnection | onsignalingstatechange [signalingState:Optional("have-remote-offer")]
2020-06-29 09:36:44.206525+0200 [421:17347] iosrtc:RTCPeerConnection onEvent() | [type:signalingstatechange, data:{"signalingState":"have-remote-offer","type":"signalingstatechange"}] +28ms
2020-06-29 09:36:44.216097+0200 [421:17598] PluginRTCPeerConnection | onaddtrack
2020-06-29 09:36:44.222287+0200 [421:17598] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(0x22b9d7180 0x22abaf9f8 0x22b8ec6ac 0x259313dbc 0x10128cd18 0x101290f70 0x10128c788 0x10206e364 0x1023de948 0x1023dd9f0 0x1023dd760 0x102120ef0 0x1020911a0 0x101ff3e9c 0x101ff3e18 0x22b5f52c0 0x22b5f5220 0x22b5f8cdc)
libc++abi.dylib: terminating with uncaught exception of type NSException

Steps to reproduce

Issue occurs every time during call start.

Expected results

Actual results

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 40 (29 by maintainers)

Most upvoted comments

@hthetiot my proposal for #533 is:

/** New track as been added. */
func peerConnection(_ peerConnection: RTCPeerConnection, didAdd rtpReceiver: RTCRtpReceiver, streams:[RTCMediaStream]) {

	NSLog("PluginRTCPeerConnection | onaddtrack")

	// TODO investigate why no stream sometimes and confirm still the case.
        let pluginMediaTrack = PluginMediaStreamTrack(rtcMediaStreamTrack: rtpReceiver.track!)

        if (streams.isEmpty) {
            self.eventListener([
                "type": "track",
                "track": pluginMediaTrack.getJSON(),
            ])
        } else {
            let pluginMediaStream = getPluginMediaStream(stream: streams[0]);

            self.eventListener([
                "type": "track",
                "track": pluginMediaTrack.getJSON(),
                "streamId": pluginMediaStream!.id,
                "stream": pluginMediaStream!.getJSON()
            ])
        }
}