Bug 1569004 - Convert dom.timeout.max_consecutive_callbacks_ms to static pref. r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 03:07:41 +0000
changeset 485158 a8d9b6cde064b1a18b9824566882a7b06c31f3ef
parent 485157 5986fb6ed82ffba333cd2ef5095b78e283cc86e7
child 485159 0708d16f56de796ac01b7399190d50758d09c80c
push id36360
push userccoroiu@mozilla.com
push dateMon, 29 Jul 2019 21:38:39 +0000
treeherdermozilla-central@927abd2c418b [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.timeout.max_consecutive_callbacks_ms to static pref. r=njn Converts dom.timeout.max_consecutive_callbacks_ms varcache pref in TimeoutManager.cpp to static pref, removes associated variables and all.js entry, and adds entry to StaticPrefList.yaml. Differential Revision: https://phabricator.services.mozilla.com/D39425
dom/base/TimeoutManager.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -409,21 +409,16 @@ void TimeoutManager::UpdateBudget(const 
 // timer code can handle, really. See DELAY_INTERVAL_LIMIT in
 // nsTimerImpl.h for details.
 #define DOM_MAX_TIMEOUT_VALUE DELAY_INTERVAL_LIMIT
 
 uint32_t TimeoutManager::sNestingLevel = 0;
 
 namespace {
 
-// The maximum number of milliseconds to allow consecutive timer callbacks
-// to run in a single event loop runnable.
-#define DEFAULT_MAX_CONSECUTIVE_CALLBACKS_MILLISECONDS 4
-uint32_t gMaxConsecutiveCallbacksMilliseconds;
-
 // Only propagate the open window click permission if the setTimeout() is equal
 // to or less than this value.
 #define DEFAULT_DISABLE_OPEN_CLICK_DELAY 0
 int32_t gDisableOpenClickDelay;
 
 }  // anonymous namespace
 
 TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow,
@@ -462,20 +457,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddUintVarCache(&gMaxConsecutiveCallbacksMilliseconds,
-                               "dom.timeout.max_consecutive_callbacks_ms",
-                               DEFAULT_MAX_CONSECUTIVE_CALLBACKS_MILLISECONDS);
-
   Preferences::AddIntVarCache(&gDisableOpenClickDelay,
                               "dom.disable_open_click_delay",
                               DEFAULT_DISABLE_OPEN_CLICK_DELAY);
   Preferences::AddIntVarCache(&gBackgroundBudgetRegenerationFactor,
                               "dom.timeout.background_budget_regeneration_rate",
                               DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR);
   Preferences::AddIntVarCache(&gForegroundBudgetRegenerationFactor,
                               "dom.timeout.foreground_budget_regeneration_rate",
@@ -677,17 +668,17 @@ void TimeoutManager::RunTimeout(const Ti
   if (mWindow.IsSuspended()) {
     return;
   }
 
   Timeouts& timeouts(aProcessIdle ? mIdleTimeouts : mTimeouts);
 
   // Limit the overall time spent in RunTimeout() to reduce jank.
   uint32_t totalTimeLimitMS =
-      std::max(1u, gMaxConsecutiveCallbacksMilliseconds);
+      std::max(1u, StaticPrefs::dom_timeout_max_consecutive_callbacks_ms());
   const TimeDuration totalTimeLimit =
       TimeDuration::Min(TimeDuration::FromMilliseconds(totalTimeLimitMS),
                         TimeDuration::Max(TimeDuration(), mExecutionBudget));
 
   // Allow up to 25% of our total time budget to be used figuring out which
   // timers need to run.  This is the initial loop in this method.
   const TimeDuration initialTimeLimit =
       TimeDuration::FromMilliseconds(totalTimeLimit.ToMilliseconds() / 4);
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1814,16 +1814,23 @@
 
 # Should we defer timeouts and intervals while loading a page.  Released
 # on Idle or when the page is loaded.
 - name: dom.timeout.defer_during_load
   type: bool
   value: true
   mirror: always
 
+# Maximum amount of time in milliseconds consecutive setTimeout()/setInterval()
+# callback are allowed to run before yielding the event loop.
+- name: dom.timeout.max_consecutive_callbacks_ms
+  type: uint32_t
+  value: 4
+  mirror: always
+
 # Maximum deferral time for setTimeout/Interval in milliseconds
 - name: dom.timeout.max_idle_defer_ms
   type: uint32_t
   value: 10*1000
   mirror: always
 
 # Delay in ms from document load until we start throttling background timeouts.
 - name: dom.timeout.throttling_delay
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5446,20 +5446,16 @@ pref("browser.sanitizer.loglevel", "Warn
 // When a user cancels this number of authentication dialogs coming from
 // a single web page in a row, all following authentication dialogs will
 // be blocked (automatically canceled) for that page. The counter resets
 // when the page is reloaded.
 // To disable all auth prompting, set the limit to 0.
 // To disable blocking of auth prompts, set the limit to -1.
 pref("prompts.authentication_dialog_abuse_limit", 2);
 
-// Maximum amount of time in milliseconds consecutive setTimeout()/setInterval()
-// callback are allowed to run before yielding the event loop.
-pref("dom.timeout.max_consecutive_callbacks_ms", 4);
-
 // Payment Request API preferences
 pref("dom.payments.loglevel", "Warn");
 pref("dom.payments.defaults.saveCreditCard", false);
 pref("dom.payments.defaults.saveAddress", true);
 pref("dom.payments.request.supportedRegions", "US,CA");
 
 #ifdef MOZ_ASAN_REPORTER
 pref("asanreporter.apiurl", "https://anf1.fuzzing.mozilla.org/crashproxy/submit/");