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
--- 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;