title: How to properly close a peerconnection
body: <p>I have a voip app using webrtc. I recently redesigned a lot of the code to make the signaling a lot more consistent. The only big problem I have now is that when I close the peerconnection the app crashes on some internal opengl code. I use this code to close the connection:  </p>
  
  <pre><code>[peerConnection removeStream:lms];
  [peerConnection close];
  peerConnection = nil;
  </code></pre>
  
  <p>The code I used previously deleted pretty much anything related to webrtc, but I found out that a lot of object can be reused and only have to be inited at the start of the app. What do I have to do to make sure the app doesn't crash everything I end a call?  </p>
  
  <ul>
  <li>I'm using revision 6825</li>
  <li>I'm using xcode 5.1.1</li>
  <li>Testing on an iPad 4th generation, running iOS7  </li>
  </ul>
  
  <p>Edit:<br>
  I moved the above code to a background thread and it no longer crashes. But now, after a few calls, my log gets spammed with the following line (about 3 or 4 times per second):  </p>
  
  <pre><code>Failed to make complete framebuffer object 8cdd
  </code></pre>
  
  <p>This is the last part of the log history when this happens:  </p>
  
  <pre><code>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 *)&lt;RTCPeerConnection: 0x157c9640&gt;
  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 *)&lt;RTCPeerConnection: 0x19a62e30&gt;
  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
  </code></pre>