Bug 1414150 - Remove the "idle_queue.*" prefs. r=farre.

There's no good reason why these can't be code constants.

Especially given that, due to a bug, changes to the
"idle_queue.{min,long}_period" constants were not being passed onto the C++
code!

Here's why: those two prefs were specified as integers in all.js. But we used
AddFloatVarCache() to set up the reading of those prefs. libpref fakes floats
by storing them as strings and then converting them to floats when they are
read.

Which means that AddFloatVarCache() used to fail to get the value from all.js
-- because there's a type mismatch, int vs. string -- and instead use the
fallback default. That value is the same as the one in all.js, which is lucky.
But if someone changed the value in about:config to 100 (an integer), a similar
failure would have occured and the value used by the C++ code wouldn't be
updated!

Also note that idle_queue.max_timer_thread_bound did not have a value in
all.js.

What a mess!

--HG--
extra : rebase_source : 86f8fa905163803eb95007609c029e18c2c4f586
This commit is contained in:
Nicholas Nethercote 2017-11-08 07:54:16 +11:00
Родитель 8f7cdde0dc
Коммит 79aa95fa24
3 изменённых файлов: 16 добавлений и 66 удалений

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

@ -3213,9 +3213,6 @@ pref("dom.global_stop_script", true);
// Time (milliseconds) between throttled idle callbacks.
pref("dom.idle_period.throttled_length", 10000);
// The amount of idle time (milliseconds) reserved for a long idle period
pref("idle_queue.long_period", 50);
// Support the input event queue on the main thread of content process
pref("input_event_queue.supported", true);
@ -3232,14 +3229,6 @@ pref("input_event_queue.default_duration_per_event", 1);
// required to process the following input events.
pref("input_event_queue.count_for_prediction", 9);
// The minimum amount of time (milliseconds) required for an idle
// period to be scheduled on the main thread. N.B. that
// layout.idle_period.time_limit adds padding at the end of the idle
// period, which makes the point in time that we expect to become busy
// again be:
// now + idle_queue.min_period + layout.idle_period.time_limit
pref("idle_queue.min_period", 3);
// Hang monitor timeout after which we kill the browser, in seconds
// (0 is disabled)
// Disabled on all platforms per bug 705748 until the found issues are

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

@ -11,11 +11,18 @@
#include "nsRefreshDriver.h"
#include "nsThreadUtils.h"
#define DEFAULT_LONG_IDLE_PERIOD 50.0f
#define DEFAULT_MIN_IDLE_PERIOD 3.0f
#define DEFAULT_MAX_TIMER_THREAD_BOUND 5
// The amount of idle time (milliseconds) reserved for a long idle period.
static const double kLongIdlePeriodMS = 50.0;
const uint32_t kMaxTimerThreadBoundClamp = 15;
// The minimum amount of time (milliseconds) required for an idle period to be
// scheduled on the main thread. N.B. layout.idle_period.time_limit adds
// padding at the end of the idle period, which makes the point in time that we
// expect to become busy again be:
// now + kMinIdlePeriodMS + layout.idle_period.time_limit
static const double kMinIdlePeriodMS = 3.0;
static const uint32_t kMaxTimerThreadBound = 5; // milliseconds
static const uint32_t kMaxTimerThreadBoundClamp = 15; // milliseconds
namespace mozilla {
@ -27,15 +34,15 @@ MainThreadIdlePeriod::GetIdlePeriodHint(TimeStamp* aIdleDeadline)
TimeStamp now = TimeStamp::Now();
TimeStamp currentGuess =
now + TimeDuration::FromMilliseconds(GetLongIdlePeriod());
now + TimeDuration::FromMilliseconds(kLongIdlePeriodMS);
currentGuess = nsRefreshDriver::GetIdleDeadlineHint(currentGuess);
currentGuess = NS_GetTimerDeadlineHintOnCurrentThread(currentGuess, GetMaxTimerThreadBound());
currentGuess = NS_GetTimerDeadlineHintOnCurrentThread(currentGuess, kMaxTimerThreadBound);
// If the idle period is too small, then just return a null time
// to indicate we are busy. Otherwise return the actual deadline.
TimeDuration minIdlePeriod =
TimeDuration::FromMilliseconds(GetMinIdlePeriod());
TimeDuration::FromMilliseconds(kMinIdlePeriodMS);
bool busySoon = currentGuess.IsNull() ||
(now >= (currentGuess - minIdlePeriod)) ||
currentGuess < mLastIdleDeadline;
@ -50,52 +57,7 @@ MainThreadIdlePeriod::GetIdlePeriodHint(TimeStamp* aIdleDeadline)
/* static */ float
MainThreadIdlePeriod::GetLongIdlePeriod()
{
MOZ_ASSERT(NS_IsMainThread());
static float sLongIdlePeriod = DEFAULT_LONG_IDLE_PERIOD;
static bool sInitialized = false;
if (!sInitialized && Preferences::IsServiceAvailable()) {
sInitialized = true;
Preferences::AddFloatVarCache(&sLongIdlePeriod, "idle_queue.long_period",
DEFAULT_LONG_IDLE_PERIOD);
}
return sLongIdlePeriod;
}
/* static */ float
MainThreadIdlePeriod::GetMinIdlePeriod()
{
MOZ_ASSERT(NS_IsMainThread());
static float sMinIdlePeriod = DEFAULT_MIN_IDLE_PERIOD;
static bool sInitialized = false;
if (!sInitialized && Preferences::IsServiceAvailable()) {
sInitialized = true;
Preferences::AddFloatVarCache(&sMinIdlePeriod, "idle_queue.min_period",
DEFAULT_MIN_IDLE_PERIOD);
}
return sMinIdlePeriod;
}
/* static */ uint32_t
MainThreadIdlePeriod::GetMaxTimerThreadBound()
{
MOZ_ASSERT(NS_IsMainThread());
static uint32_t sMaxTimerThreadBound = DEFAULT_MAX_TIMER_THREAD_BOUND;
static bool sInitialized = false;
if (!sInitialized && Preferences::IsServiceAvailable()) {
sInitialized = true;
Preferences::AddUintVarCache(&sMaxTimerThreadBound, "idle_queue.max_timer_thread_bound",
DEFAULT_MAX_TIMER_THREAD_BOUND);
}
return std::max(sMaxTimerThreadBound, kMaxTimerThreadBoundClamp);
return kLongIdlePeriodMS;
}
} // namespace mozilla

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

@ -23,8 +23,7 @@ public:
}
static float GetLongIdlePeriod();
static float GetMinIdlePeriod();
static uint32_t GetMaxTimerThreadBound();
private:
virtual ~MainThreadIdlePeriod() {}