Bug 1540573 - P5. Only "always throttle" media download to the readahead on cellular connections. r=jya

Normally when downloading media data we throttle the download only if we're
ahead of the read cursor more than the "readahead limit", and if we estimate
that the connection is fast enough that we'll be able to download at a rate
fast enough to playback in real time if we resume it later.

On mobile we additionally override this so that we always throttle the download
once we're ahead of the read cursor by the readahead limit. This is to save
data.  I think we can relax this to only do this override if we're on a
cellular connection; if we're on WiFi we can assume data is cheap.

Differential Revision: https://phabricator.services.mozilla.com/D26234

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Pearce 2019-05-03 02:44:31 +00:00
Родитель c13f163bd6
Коммит c957fbd2ef
2 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -11,6 +11,7 @@
#include "BaseMediaResource.h"
#include "MediaShutdownManager.h"
#include "mozilla/StaticPrefs.h"
#include "VideoUtils.h"
namespace mozilla {
@ -458,8 +459,9 @@ MediaStatistics ChannelMediaDecoder::GetStatistics(
bool ChannelMediaDecoder::ShouldThrottleDownload(
const MediaStatistics& aStats) {
// 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.
// (so that we always throttle at the readahead limit on mobile if using
// a cellular network) or if the download is fast enough that there's no
// concern about playback being interrupted.
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE(GetStateMachine(), false);
@ -472,8 +474,9 @@ bool ChannelMediaDecoder::ShouldThrottleDownload(
return false;
}
if (Preferences::GetBool("media.throttle-regardless-of-download-rate",
false)) {
if (OnCellularConnection() &&
Preferences::GetBool(
"media.throttle-cellular-regardless-of-download-rate", false)) {
return true;
}

Просмотреть файл

@ -553,9 +553,10 @@ pref("browser.meta_refresh_when_inactive.disabled", true);
// prevent video elements from preloading too much data
pref("media.preload.default", 1); // default to preload none
pref("media.preload.auto", 2); // preload metadata if preload=auto
// On mobile we'll throttle the download once the readahead_limit is hit,
// even if the download is slow. This is to preserve battery and data.
pref("media.throttle-regardless-of-download-rate", true);
// On mobile we throttle the download once the readahead_limit is hit
// if we're using a cellular connection, even if the download is slow.
// This is to preserve battery and data.
pref("media.throttle-cellular-regardless-of-download-rate", true);
// Number of video frames we buffer while decoding video.
// On Android this is decided by a similar value which varies for