当我调用 peerconnection->Close() 时 WebRtc Native-Crashed [英] WebRtc Native-Crashed when I call peerconnection->Close()

查看:99
本文介绍了当我调用 peerconnection->Close() 时 WebRtc Native-Crashed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何关闭或销毁 PeerConnectionInterface 对象?当我尝试这样做时它崩溃了.

How to close or destruct a PeerConnectionInterface object? It crashed when I'm trying to do so.

我有一个这样声明的对象:rtc::scoped_refptr_peerConnection;

I have an object declared like this: rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;

在我通过工厂创建 PeerConnectionInterface 后它工作正常.

It works fine after I create the PeerConnectionInterface by factory.

但是,当会话结束时,我尝试调用 _peerConnection->Close();程序崩溃了.

However, when the session is over and I try to call _peerConnection->Close(); The program crashed.

我也尝试调用 _peerConnection.release()->Release();也崩溃了.

And I also try to call _peerConnection.release()->Release(); Crashed as well.

我在WebRtc源代码的PeerConnection.cc中打印日志,发现这里崩溃了,在Close()函数和~PeerConnection()函数中:

I print logs in PeerConnection.cc which is from the source code of WebRtc, and find that it crashed here, which is in Close() function and ~PeerConnection() function:

webrtc_session_desc_factory_.reset();//PeerConnection.cc

声明是std::unique_ptrwebrtc_session_desc_factory_;

于是我继续登录WebRtcSessionDescriptionFactory.cc,~WebRtcSessionDescriptionFactory()函数.在这个函数中崩溃了:FailPendingRequests().

So I continue to log in WebRtcSessionDescriptionFactory.cc, the ~WebRtcSessionDescriptionFactory() function. Crashed in this function:FailPendingRequests().

进入FailPendingRequests()函数:

Entered the FailPendingRequests() function:

RTC_DCHECK(signaling_thread_->IsCurrent());
  while (!create_session_description_requests_.empty()) {
    const CreateSessionDescriptionRequest& request =
        create_session_description_requests_.front();
    //Crashed here in third or fourth loop
    PostCreateSessionDescriptionFailed(request.observer,
        ((request.type == CreateSessionDescriptionRequest::kOffer) ?
            "CreateOffer" : "CreateAnswer") + reason);
    create_session_description_requests_.pop();
  }

我将非常感谢您的任何建议!

I will be really grateful for any suggestion!

推荐答案

我在 iOS 中实现 Kurento 库时遇到了同样的问题.解决这个问题的关键是以正确的方式处理资源.

I faced the same issue in iOS when implemented Kurento Library. The key to fix this issue is to dispose the resources in the right manner.

我遵循的步骤:

创建顺序:

创建 WebRTCPeer 对象

Created WebRTCPeer object

创建 RoomClient 对象

Created RoomClient object

一旦 RoomClient 连接,生成 SDP 报价.

Once RoomClient connected, generated SDP Offer.

等等.

处理顺序:

首先断开 RoomClient.

Disconnected RoomClient first.

密切关注 WebRTC 事件中的RTCIceConnectionState"、RTCIceGatheringState".

Kept an eye on "RTCIceConnectionState", "RTCIceGatheringState" in the WebRTC events.

一旦RTCIceConnectionState"关闭且 iceGatheringState 为RTCIceGatheringStateComplete",则释放 WebRTCPeer 对象.

Once "RTCIceConnectionState" is closed and iceGatheringState is "RTCIceGatheringStateComplete", then disposed WebRTCPeer object.

这样问题就解决了,否则资源被初始化,主对象被释放,导致崩溃.

This way the problem got resolved, otherwise resources were initialised and main object were disposed, which results in crashes.

希望有帮助!

这篇关于当我调用 peerconnection->Close() 时 WebRtc Native-Crashed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆