Bug 1401461. P2 - don't call mChannelStatistics.AddBytes() if the data is from an old channel. r=gerald
☠☠ backed out by 58e2fc0076b7 ☠ ☠
authorJW Wang <jwwang@mozilla.com>
Wed, 20 Sep 2017 14:41:17 +0800
changeset 434099 ddfa978c27f7125395975b1e3f6b6acfd12a753f
parent 434098 0ceb7e5789f4e88468c9b2c3ed43ba762aa87b16
child 434100 ae92b4765e63b78e24dfdf89d2c0d8c404a56da8
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1401461
milestone57.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 1401461. P2 - don't call mChannelStatistics.AddBytes() if the data is from an old channel. r=gerald MozReview-Commit-ID: GIVwoGpo43R
dom/media/ChannelMediaResource.cpp
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -417,18 +417,23 @@ nsresult
 ChannelMediaResource::OnDataAvailable(uint32_t aLoadID,
                                       nsIInputStream* aStream,
                                       uint32_t aCount)
 {
   // This might happen off the main thread.
 
   RefPtr<ChannelMediaResource> self = this;
   nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
-    "ChannelMediaResource::OnDataAvailable",
-    [self, aCount]() { self->mChannelStatistics.AddBytes(aCount); });
+    "ChannelMediaResource::OnDataAvailable", [self, aCount, aLoadID]() {
+      if (aLoadID != self->mLoadID) {
+        // Ignore data from the old channel.
+        return;
+      }
+      self->mChannelStatistics.AddBytes(aCount);
+    });
   mCallback->AbstractMainThread()->Dispatch(r.forget());
 
   Closure closure{ aLoadID, this };
   uint32_t count = aCount;
   while (count > 0) {
     uint32_t read;
     nsresult rv =
       aStream->ReadSegments(CopySegmentToCache, &closure, count, &read);