Bug 1374475 - Don't throttle download of media files under 8MB in size. r=jwwang
authorChris Pearce <cpearce@mozilla.com>
Tue, 20 Jun 2017 13:03:49 +1200
changeset 364813 d1adec83acac5da5f6037a88a13d83eec1b88980
parent 364812 f4a46277935b2702c2a0351204233adb9d7bb3df
child 364814 040bfd7cf6a8252ce9066eea93db22cd8882dd3c
push id45068
push usercpearce@mozilla.com
push dateTue, 20 Jun 2017 05:01:29 +0000
treeherderautoland@d1adec83acac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1374475, 1373618
milestone56.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 1374475 - Don't throttle download of media files under 8MB in size. r=jwwang The startup latency for an HTTP transaction can be high, this adds delay when we're seeking into an unbuffered range. So we should not throttle the download for small files, to speed up seeking. This also works around the problem in bug 1373618 in the case where the download is fast enough for the entire file to predownload before a seek. MozReview-Commit-ID: A8Hqi71IJ1H
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1025,16 +1025,25 @@ bool
 MediaDecoder::ShouldThrottleDownload()
 {
   // We throttle the download if either the throttle override pref is set
   // (so that we can always throttle in Firefox on mobile) or if the download
   // is fast enough that there's no concern about playback being interrupted.
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE(mDecoderStateMachine, false);
 
+  int64_t length = mResource->GetLength();
+  if (length > 0 &&
+      length <= int64_t(MediaPrefs::MediaMemoryCacheMaxSize()) * 1024) {
+    // Don't throttle the download of small resources. This is to speed
+    // up seeking, as seeks into unbuffered ranges would require starting
+    // up a new HTTP transaction, which adds latency.
+    return false;
+  }
+
   if (Preferences::GetBool("media.throttle-regardless-of-download-rate",
                            false)) {
     return true;
   }
 
   MediaStatistics stats = GetStatistics();
   if (!stats.mDownloadRateReliable || !stats.mPlaybackRateReliable) {
     return false;