How to properly close peerconnection

I have a voip application using webrtc. I recently reworked a lot of code to make the alarms much more consistent. The only problem I am currently facing is that when I close the peerconnection, the application crashes on some internal opengl code. I am using this code to close the connection:

[peerConnection removeStream:lms];
[peerConnection close];
peerConnection = nil;

      

The code I used earlier removed almost everything related to webrtc, but I found that many objects are reusable and only need to be entered at the beginning of the application. What do I need to do to make sure the app doesn't crash everything I finish?

  • I am using revision 6825
  • I am using xcode 5.1.1
  • Testing on a 4th generation iPad running iOS7

Edit:
I moved the above code to a background thread and it won't work anymore. But now, after a few calls, my log is receiving spam with the following line (about 3 or 4 times per second):

Failed to make complete framebuffer object 8cdd

      

This is the last part of the history of the journal when this happens:

2014-10-14 11:53:45.045 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)2
2014-10-14 11:53:45.046 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)3
2014-10-14 11:53:50.732 BeeldZorgApp[4912:3903] peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)<RTCPeerConnection: 0x157c9640>
2014-10-14 11:53:50.742 BeeldZorgApp[4912:3903] peerConnection iceConnectionChanged:(RTCICEConnectionState)6
2014-10-14 11:53:50.743 BeeldZorgApp[4912:3903] peerConnection signalingStateChanged:(RTCSignalingState)5
2014-10-14 11:53:59.955 BeeldZorgApp[4912:3903] peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)<RTCPeerConnection: 0x19a62e30>
2014-10-14 11:53:59.980 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.028 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.091 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.119 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.152 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.185 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.218 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.252 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.284 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.319 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.352 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.384 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.417 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.451 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.486 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.518 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd
2014-10-14 11:54:00.552 BeeldZorgApp[4912:60b] Failed to make complete framebuffer object 8cdd

      

+3


source to share


2 answers


It turns out that RTCEAGLVideoViews needs to be removed from their supervisor before moving from the view controller. Now I am using the following code to clean up:



//these are both RTCEAGLVideoViews
[remoteVideoView removeFromSuperview];
[localVideoView removeFromSuperview];
[peerConnection removeStream:lms];
[peerConnection close];
peerConnection = nil;

      

+6


source


If you set peerConnection

it to zero, you will get an error in this view controller when you try to call someone again (a second time). I think it is setting the peerConnection

value of the PeerConnectionFactory of the static class. So when you call the peerConnectionWithConfiguration factory method, you will get a null value. My suggestion is that the method is close()

sufficient (with swift):

self.remoteVideoView.removeFromSuperview()
self.localVideoView.removeFromSuperview()
self.peerConnection.removeStream(self.mediaStream)
self.peerConnection.close()

      



PS: I am using the latest version of the webrtc library

+1


source







All Articles