Bug 1663216 - Have a pref to control unthrottled timers in background tabs, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D89295
This commit is contained in:
Olli Pettay 2020-09-07 13:23:34 +00:00
parent 7e31de8547
commit f50042da80
2 changed files with 7 additions and 6 deletions

View File

@ -243,15 +243,16 @@ TimeDuration TimeoutManager::MinSchedulingDelay() const {
isBackground ? TimeDuration::FromMilliseconds(
StaticPrefs::dom_min_background_timeout_value())
: TimeDuration();
if (BudgetThrottlingEnabled(isBackground) &&
mExecutionBudget < TimeDuration()) {
bool budgetThrottlingEnabled = BudgetThrottlingEnabled(isBackground);
if (budgetThrottlingEnabled && mExecutionBudget < TimeDuration()) {
// Only throttle if execution budget is less than 0
double factor = 1.0 / GetRegenerationFactor(mWindow.IsBackgroundInternal());
return TimeDuration::Max(unthrottled, -mExecutionBudget.MultDouble(factor));
}
if (!mThrottleTimeouts && isBackground) {
if (!budgetThrottlingEnabled && isBackground) {
return TimeDuration::FromMilliseconds(
StaticPrefs::dom_min_background_timeout_value_before_throttling());
StaticPrefs::
dom_min_background_timeout_value_without_budget_throttling());
}
return unthrottled;

View File

@ -2159,8 +2159,8 @@
value: 1000
mirror: always
# Timeout clamp in ms for background windows before throttling has started.
- name: dom.min_background_timeout_value_before_throttling
# Timeout clamp in ms for background windows when throttling isn't enabled.
- name: dom.min_background_timeout_value_without_budget_throttling
type: int32_t
value: 1000
mirror: always