diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 5776d2d9a60..a7be911232c 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -1896,6 +1896,7 @@ PeerConnectionImpl::IceGatheringStateChange( NS_DISPATCH_NORMAL); } +#ifdef MOZILLA_INTERNAL_API static bool isDone(PCImplIceConnectionState state) { return state != PCImplIceConnectionState::Checking && state != PCImplIceConnectionState::New; @@ -1910,6 +1911,7 @@ static bool isFailed(PCImplIceConnectionState state) { return state == PCImplIceConnectionState::Failed || state == PCImplIceConnectionState::Disconnected; } +#endif nsresult PeerConnectionImpl::IceConnectionStateChange_m(PCImplIceConnectionState aState) @@ -2185,11 +2187,6 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) { ASSERT_ON_THREAD(query->iceCtx->thread()); - // NrIceCtx must be destroyed on STS, so it is not safe to dispatch it back - // to main. - RefPtr iceCtxTmp(query->iceCtx); - query->iceCtx = nullptr; - // Gather stats from pipelines provided (can't touch mMedia + stream on STS) for (size_t p = 0; p < query->pipelines.Length(); ++p) { @@ -2333,6 +2330,11 @@ PeerConnectionImpl::ExecuteStatsQuery_s(RTCStatsQuery *query) { &(query->report)); } + // NrIceCtx and NrIceMediaStream must be destroyed on STS, so it is not safe + // to dispatch them back to main. + // We clear streams first to maintain destruction order + query->streams.Clear(); + query->iceCtx = nullptr; return NS_OK; }