断开连接时Webrtc peerconnection中的随机本机崩溃

时间:2017-05-30 11:37:32

标签: android android-ndk webrtc

我正在使用webrtc进行视频通话。我的用例是我一个接一个地连接队列中的用户。因此,连接到user1,与user1结束连接,然后连接到user2,依此类推。

有时在断开用户连接并关闭对等连接时,我遇到了这个本机崩溃

E/rtc(6882): #\
05-26 17:30:44.374: E/rtc(6882): # Fatal error in ../../webrtc/sdk/android/src/jni/peerconnection_jni.cc, line 1074\
05-26 17:30:44.374: E/rtc(6882): # last system error: 17\
05-26 17:30:44.374: E/rtc(6882): # Check failed: 0 == (reinterpret_cast<PeerConnectionInterface*>(j_p))->Release() (0 vs. 1)\
05-26 17:30:44.374: E/rtc(6882): # Unexpected refcount.\
05-26 17:30:44.374: E/rtc(6882): #\

这种崩溃是非常随机发生的,而我可以猜到的是,在处置时会有一些对peerconnection的引用。

以下是我处理对等连接的代码,我正在重复使用本地媒体流进行新连接。

videoCapturer.stopCapture();
if (peerConnection != null) {
        peerConnection.close();
        peerConnection.removeStream(localMediaStream);
        peerConnection.dispose();
        peerConnection = null;
}

是上述片段正确的处理对等连接的方法吗?这次崩溃的随机性可能是什么原因?泄露的引用是Java层还是本机层?

1 个答案:

答案 0 :(得分:2)

如果要从同一工厂创建多个peerConnections并进行处理,则会出现这些崩溃。

解决方法:停止处理peerConnection,因为peerConnection.dispose();会破坏本地流等。
只需使用peerConnection.close();并仅将peerConnection.dispose();用于最终的peerConnection对象。

将错误标记为75437691,以获取有关此

的更新