From 3d1e87597e348480cbce9df525e244a804d523ff Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 20 Jun 2017 13:03:49 +1200 Subject: [PATCH] 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 --HG-- extra : rebase_source : 30648d3ad62b8c0417b1244c896b43b670382e9c --- dom/media/MediaDecoder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index cbcc4b538e42..9d13360d9e9e 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -1030,6 +1030,15 @@ MediaDecoder::ShouldThrottleDownload() 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;