Bug 1133625: Part2. Don't accept buffer exceeding our threshold. r=cajbir a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 20 Feb 2015 14:19:14 +1300
changeset 240865 419b32569a768f37ca35d1e18bac9a0ef36b515a
parent 240864 77ec05774a77df5ecbd7a70a7a8bf354f626f2e9
child 240866 030fa1665346dfa94d1f72a1c7830644664ecf08
push id7674
push userrgiles@mozilla.com
push dateMon, 23 Feb 2015 08:08:48 +0000
treeherdermozilla-aurora@419b32569a76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir, lmandel
bugs1133625
milestone37.0a2
Bug 1133625: Part2. Don't accept buffer exceeding our threshold. r=cajbir a=lmandel YouTube attempts to load data in excess of 8MB when close to the end of the video, and never attempts to re-append should it error. As such, the sourcebuffer threshold can't be set to lower than 8MB with this change.
dom/media/mediasource/SourceBuffer.cpp
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -556,18 +556,19 @@ SourceBuffer::PrepareAppend(const uint8_
     // We notify that we've evicted from the time range 0 through to
     // the current start point.
     mMediaSource->NotifyEvicted(0.0, newBufferStartTime);
   }
 
   // See if we have enough free space to append our new data.
   // As we can only evict once we have playable data, we must give a chance
   // to the DASH player to provide a complete media segment.
-  if ((mTrackBuffer->GetSize() > mEvictionThreshold - aLength) &&
-      !mTrackBuffer->HasOnlyIncompleteMedia()) {
+  if (aLength > mEvictionThreshold ||
+      ((mTrackBuffer->GetSize() > mEvictionThreshold - aLength) &&
+       !mTrackBuffer->HasOnlyIncompleteMedia())) {
     aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
     return nullptr;
   }
 
   nsRefPtr<LargeDataBuffer> data = new LargeDataBuffer();
   if (!data->AppendElements(aData, aLength)) {
     aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
     return nullptr;