Bug 1533261: Check whether PeerConnectionCtx is active before calling GetInstance. r=mjf
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 08 Mar 2019 15:25:20 +0000
changeset 521168 2ccf4b1b18ada3b0f67f32a26b2a012916e19e9f
parent 521167 cd9ef3b60bc328f4fa3bb63dae215cec08f92e7b
child 521169 ea20a62a2fa073eb77f1f03ad5a3987191d8626b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf
bugs1533261
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533261: Check whether PeerConnectionCtx is active before calling GetInstance. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D22530
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -2472,18 +2472,19 @@ void PeerConnectionImpl::UpdateSignaling
 bool PeerConnectionImpl::IsClosed() const {
   return mSignalingState == PCImplSignalingState::SignalingClosed;
 }
 
 bool PeerConnectionImpl::HasMedia() const { return mMedia; }
 
 PeerConnectionWrapper::PeerConnectionWrapper(const std::string& handle)
     : impl_(nullptr) {
-  if (PeerConnectionCtx::GetInstance()->mPeerConnections.find(handle) ==
-      PeerConnectionCtx::GetInstance()->mPeerConnections.end()) {
+  if (!PeerConnectionCtx::isActive() ||
+      (PeerConnectionCtx::GetInstance()->mPeerConnections.find(handle) ==
+       PeerConnectionCtx::GetInstance()->mPeerConnections.end())) {
     return;
   }
 
   PeerConnectionImpl* impl =
       PeerConnectionCtx::GetInstance()->mPeerConnections[handle];
 
   if (!impl->media()) return;
 
@@ -2797,17 +2798,17 @@ RefPtr<RTCStatsQueryPromise> PeerConnect
 
   for (size_t p = 0; p < aPipelines.Length(); ++p) {
     MOZ_ASSERT(aPipelines[p]);
     MOZ_ASSERT(aPipelines[p]->Conduit());
     if (!aPipelines[p] || !aPipelines[p]->Conduit()) {
       // continue if we don't have a valid conduit
       continue;
     }
-    const MediaPipeline &mp = *aPipelines[p];
+    const MediaPipeline& mp = *aPipelines[p];
     auto asVideo = mp.Conduit()->AsVideoSessionConduit();
     nsString kind = asVideo.isNothing() ? NS_LITERAL_STRING("audio")
                                         : NS_LITERAL_STRING("video");
     nsString idstr = kind + NS_LITERAL_STRING("_");
     idstr.AppendInt(static_cast<uint32_t>(p));
 
     // TODO(@@NG):ssrcs handle Conduits having multiple stats at the same level
     // This is pending spec work
@@ -2869,17 +2870,17 @@ RefPtr<RTCStatsQueryPromise> PeerConnect
           s.mPacketsSent.Construct(mp.RtpPacketsSent());
           s.mBytesSent.Construct(mp.RtpBytesSent());
 
           // Fill in packet type statistics
           webrtc::RtcpPacketTypeCounter counters;
           if (mp.Conduit()->GetSendPacketTypeStats(&counters)) {
             s.mNackCount.Construct(counters.nack_packets);
             // Fill in video only packet type stats
-            if(asVideo) {
+            if (asVideo) {
               s.mFirCount.Construct(counters.fir_packets);
               s.mPliCount.Construct(counters.pli_packets);
             }
           }
 
           // Lastly, fill in video encoder stats if this is video
           asVideo.apply([&s](auto conduit) {
             double framerateMean;