Bug 1472921 - Fix sampling interval persistence for values <1ms. r?julienw
MozReview-Commit-ID: TxKzT8MCZY
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1806,17 +1806,17 @@ BrowserGlue.prototype = {
}
}
},
// eslint-disable-next-line complexity
_migrateUI: function BG__migrateUI() {
// Use an increasing number to keep track of the current migration state.
// Completely unrelated to the current Firefox release number.
- const UI_VERSION = 71;
+ const UI_VERSION = 72;
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
let currentUIVersion;
if (Services.prefs.prefHasUserValue("browser.migration.version")) {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
} else {
// This is a new profile, nothing to migrate.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -2137,16 +2137,22 @@ BrowserGlue.prototype = {
if (currentUIVersion < 71) {
// Clear legacy saved prefs for content handlers.
let savedContentHandlers = Services.prefs.getChildList("browser.contentHandlers.types");
for (let savedHandlerPref of savedContentHandlers) {
Services.prefs.clearUserPref(savedHandlerPref);
}
}
+ if (currentUIVersion < 72) {
+ // Migrate performance tool's recording interval value from msec to usec.
+ let pref = "devtools.performance.recording.interval";
+ Services.prefs.setIntPref(pref, Services.prefs.getIntPref(pref, 1) * 1000);
+ }
+
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},
_checkForDefaultBrowser() {
// Perform default browser checking.
if (!ShellService) {
return;
--- a/devtools/client/performance-new/browser.js
+++ b/devtools/client/performance-new/browser.js
@@ -106,17 +106,19 @@ async function getRecordingPreferences(p
),
_getArrayOfStringsPref(
preferenceFront,
`devtools.performance.recording.threads`,
defaultSettings.threads
),
]);
- return { entries, interval, features, threads };
+ // The pref stores the value in usec.
+ const newInterval = interval / 1000;
+ return { entries, interval: newInterval, features, threads };
}
/**
* Take the recording settings, as defined by the getRecordingSettings selector, and
* persist them to preferences.
*
* @param {PreferenceFront} preferenceFront
* @param {object} defaultSettings See the getRecordingSettings selector for the shape
@@ -125,17 +127,18 @@ async function getRecordingPreferences(p
async function setRecordingPreferences(preferenceFront, settings) {
await Promise.all([
preferenceFront.setIntPref(
`devtools.performance.recording.entries`,
settings.entries
),
preferenceFront.setIntPref(
`devtools.performance.recording.interval`,
- settings.interval
+ // The pref stores the value in usec.
+ settings.interval * 1000
),
preferenceFront.setCharPref(
`devtools.performance.recording.features`,
JSON.stringify(settings.features)
),
preferenceFront.setCharPref(
`devtools.performance.recording.threads`,
JSON.stringify(settings.threads)
--- a/devtools/client/performance-new/store/reducers.js
+++ b/devtools/client/performance-new/store/reducers.js
@@ -50,20 +50,20 @@ function isSupportedPlatform(state = nul
return state;
}
}
// Right now all recording setting the defaults are reset every time the panel
// is opened. These should be persisted between sessions. See Bug 1453014.
/**
- * The setting for the recording interval.
+ * The setting for the recording interval. Defaults to 1ms.
* @param {number} state
*/
-function interval(state = 1, action) {
+function interval(state = 1000, action) {
switch (action.type) {
case "CHANGE_INTERVAL":
return action.interval;
case "INITIALIZE_STORE":
return action.recordingSettingsFromPreferences.interval;
default:
return state;
}
--- a/devtools/client/performance-new/test/chrome/test_perf-settings-interval.html
+++ b/devtools/client/performance-new/test/chrome/test_perf-settings-interval.html
@@ -26,18 +26,18 @@
mountAndInitializeComponent,
selectors,
getState,
recordingPreferencesCalls
} = createPerfComponent();
await mountAndInitializeComponent();
- is(selectors.getInterval(getState()), 1,
- "The interval starts out as 1");
+ is(selectors.getInterval(getState()), 1000,
+ "The interval starts out as 1000");
is(recordingPreferencesCalls.length, 0,
"No calls have been made");
const inputValue = 75;
const scaledValue = 10;
const input = document.querySelector("#perf-range-interval");
setReactFriendlyInputValue(input, inputValue);