Bug 1569004 - Convert dom.min_background_timeout_value to StaticPref. r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 19:21:47 +0000
changeset 485172 a5d0fdf989304bbb9fdad74b0f8ac15baad8ff3f
parent 485171 2655857e489d107844616ce2feeef0da41aa106a
child 485173 9f8ada36cf9bd03deb4b0e5896721371ff688d63
push id91160
push userkwright@mozilla.com
push dateMon, 29 Jul 2019 17:51:51 +0000
treeherderautoland@0a9a0b8b35fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1569004
milestone70.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 1569004 - Convert dom.min_background_timeout_value to StaticPref. r=njn Converts dom.min_background_timeout_value in TimeoutManager.cpp to static pref, removes entry in all.js, adds entry to StaticPrefList.yaml. Differential Revision: https://phabricator.services.mozilla.com/D39430
dom/base/TimeoutManager.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -30,20 +30,18 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 LazyLogModule gTimeoutLog("Timeout");
 
 static int32_t gRunningTimeoutDepth = 0;
 
 // The default shortest interval/timeout we permit
-#define DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE 1000           // 1000ms
 #define DEFAULT_MIN_TRACKING_TIMEOUT_VALUE 4                // 4ms
 #define DEFAULT_MIN_TRACKING_BACKGROUND_TIMEOUT_VALUE 1000  // 1000ms
-static int32_t gMinBackgroundTimeoutValue = 0;
 static int32_t gMinTrackingTimeoutValue = 0;
 static int32_t gMinTrackingBackgroundTimeoutValue = 0;
 static int32_t gTimeoutThrottlingDelay = 0;
 
 #define DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR 100  // 1ms per 100ms
 #define DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR 1    // 1ms per 1ms
 #define DEFAULT_BACKGROUND_THROTTLING_MAX_BUDGET 50        // 50ms
 #define DEFAULT_FOREGROUND_THROTTLING_MAX_BUDGET -1        // infinite
@@ -253,17 +251,18 @@ TimeDuration TimeoutManager::MinScheduli
   // max(1000, - (- 50) * 1/0.1) = max(1000, 500) = 1000
   //
   // mExecutionBudget is -15ms
   // factor is 0.01, which is 1 ms/100ms
   // delay is 1000ms
   // then we will compute the minimum delay:
   // max(1000, - (- 15) * 1/0.01) = max(1000, 1500) = 1500
   TimeDuration unthrottled =
-      isBackground ? TimeDuration::FromMilliseconds(gMinBackgroundTimeoutValue)
+      isBackground ? TimeDuration::FromMilliseconds(
+                         StaticPrefs::dom_min_background_timeout_value())
                    : TimeDuration();
   if (BudgetThrottlingEnabled(isBackground) &&
       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));
   }
   //
@@ -474,19 +473,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddIntVarCache(&gMinBackgroundTimeoutValue,
-                              "dom.min_background_timeout_value",
-                              DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingTimeoutValue,
                               "dom.min_tracking_timeout_value",
                               DEFAULT_MIN_TRACKING_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingBackgroundTimeoutValue,
                               "dom.min_tracking_background_timeout_value",
                               DEFAULT_MIN_TRACKING_BACKGROUND_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gTimeoutThrottlingDelay,
                               "dom.timeout.throttling_delay",
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1424,16 +1424,22 @@
   mirror: always
 
 # Timeout clamp in ms for timeouts we clamp.
 - name: dom.min_timeout_value
   type: int32_t
   value: 4
   mirror: always
 
+# Timeout clamp in ms for background windows.
+- name: dom.min_background_timeout_value
+  type: int32_t
+  value: 1000
+  mirror: always
+
 # Is support for module scripts (<script type="module">) enabled for content?
 - name: dom.moduleScripts.enabled
   type: bool
   value: true
   mirror: always
 
 # Is support for mozBrowser frames enabled?
 - name: dom.mozBrowserFramesEnabled
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1079,18 +1079,16 @@ pref("dom.storage.default_quota",      5
 pref("dom.storage.shadow_writes", true);
 pref("dom.storage.snapshot_prefill", 16384);
 pref("dom.storage.snapshot_gradual_prefill", 4096);
 pref("dom.storage.snapshot_reusing", true);
 pref("dom.storage.client_validation", true);
 
 pref("dom.send_after_paint_to_content", false);
 
-// And for background windows
-pref("dom.min_background_timeout_value", 1000);
 // Timeout clamp in ms for tracking timeouts we clamp
 // Note that this requires the privacy.trackingprotection.annotate_channels pref to be on in order to have any effect.
 pref("dom.min_tracking_timeout_value", 4);
 // And for background windows
 // Note that this requires the privacy.trackingprotection.annotate_channels pref to be on in order to have any effect.
 pref("dom.min_tracking_background_timeout_value", 4);
 // Delay in ms from document load until we start throttling background timeouts.
 pref("dom.timeout.throttling_delay", 30000);