WebRtc Native-Crashed when I call peerconnection->Close()

安稳与你 提交于 2019-12-11 11:34:32

问题


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

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

It works fine after I create the PeerConnectionInterface by factory.

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

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

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

The declare is std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_;

So I continue to log in WebRtcSessionDescriptionFactory.cc, the ~WebRtcSessionDescriptionFactory() function. Crashed in this function: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!


回答1:


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.

Steps I followed:

The order of creation:

Created WebRTCPeer object

Created RoomClient object

Once RoomClient connected, generated SDP Offer.

and so on.

The order of disposition:

Disconnected RoomClient first.

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

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.

Hope that helps!



来源:https://stackoverflow.com/questions/51074131/webrtc-native-crashed-when-i-call-peerconnection-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!