我正在使用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): #\


崩溃是非常随机发生的,据我所知,某些东西在处理时一直在引用对等连接。

这是我处理对等连接的代码,我将本地媒体流重新用于新连接。

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


以上代码段是处理对等连接的正确方法吗?崩溃的随机性可能是什么原因?泄漏的引用是在Java层还是本机层内部?

最佳答案

如果要从同一工厂创建多个peerConnection并进行处理,则将导致这些崩溃。

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

给错误75437691加上星号以获取有关此更新的信息

关于android - 断开连接时Webrtc对等连接中的随机 native 崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44261220/

10-11 22:42
查看更多