Bug 827913 - Remove no-longer-correct MOZ_ASSERT in getUserMedia. r=derf, a=akeybl
authorRandell Jesup <rjesup@jesup.org>
Tue, 08 Jan 2013 22:10:09 -0500
changeset 127189 31e9e2ae25e52d86bdd510e459b326936693d22b
parent 127188 ed901509fe6af96fb26b18e88e966c16d31c719d
child 127190 3a05f9a9eb77b4605a5bed867096ebd3bc3d615c
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf, akeybl
bugs827913
milestone20.0a2
Bug 827913 - Remove no-longer-correct MOZ_ASSERT in getUserMedia. r=derf, a=akeybl
dom/media/MediaManager.cpp
dom/media/MediaManager.h
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1063,17 +1063,19 @@ MediaManager::OnNavigation(uint64_t aWin
   if (!listeners) {
     return;
   }
 
   uint32_t length = listeners->Length();
   for (uint32_t i = 0; i < length; i++) {
     nsRefPtr<GetUserMediaCallbackMediaStreamListener> listener =
       listeners->ElementAt(i);
-    listener->Invalidate();
+    if (listener->Stream()) { // aka HasBeenActivate()ed
+      listener->Invalidate();
+    }
     listener->Remove();
   }
   listeners->Clear();
 
   RemoveWindowID(aWindowID);
   // listeners has been deleted
 }
 
@@ -1247,17 +1249,17 @@ GetUserMediaCallbackMediaStreamListener:
   mMediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
 }
 
 // Called from the MediaStreamGraph thread
 void
 GetUserMediaCallbackMediaStreamListener::NotifyFinished(MediaStreamGraph* aGraph)
 {
   mFinished = true;
-  Invalidate();
+  Invalidate(); // we know it's been activated
   NS_DispatchToMainThread(new GetUserMediaListenerRemove(mWindowID, this));
 }
 
 // Called from the MediaStreamGraph thread
 // this can be in response to our own RemoveListener() (via ::Remove()), or
 // because the DOM GC'd the DOMLocalMediaStream/etc we're attached to.
 void
 GetUserMediaCallbackMediaStreamListener::NotifyRemoved(MediaStreamGraph* aGraph)
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -99,17 +99,20 @@ public:
   }
 
   MediaStream *Stream()
   {
     return mStream;
   }
   SourceMediaStream *GetSourceStream()
   {
-    MOZ_ASSERT(mStream);
+    NS_ASSERTION(mStream,"Getting stream from never-activated GUMCMSListener");
+    if (!mStream) {
+      return nullptr;
+    }
     return mStream->AsSourceStream();
   }
 
   // implement in .cpp to avoid circular dependency with MediaOperationRunnable
   // Can be invoked from EITHER MainThread or MSG thread
   void Invalidate();
 
   void
@@ -197,19 +200,18 @@ public:
   }
 
   NS_IMETHOD
   Run()
   {
     SourceMediaStream *source = mListener->GetSourceStream();
     // No locking between these is required as all the callbacks for the
     // same MediaStream will occur on the same thread.
-    MOZ_ASSERT(source);
-    if (!source)  // paranoia
-      return NS_ERROR_FAILURE;
+    if (!source) // means the stream was never Activated()
+      return NS_OK;
 
     switch (mType) {
       case MEDIA_START:
         {
           NS_ASSERTION(!NS_IsMainThread(), "Never call on main thread");
           nsresult rv;
 
           source->SetPullEnabled(true);