Backed out changeset d2cfd29e2bb5 (bug 1380676) on Dev's request. CLOSED TREE

This commit is contained in:
Dorel Luca 2020-07-06 15:44:41 +03:00
parent a639ed9828
commit 6aa252b6bf
15 changed files with 44 additions and 57 deletions

View File

@ -9,7 +9,7 @@ function _contentHeroHandler(isload) {
function callback(entries, observer) { function callback(entries, observer) {
entries.forEach(entry => { entries.forEach(entry => {
sendAsyncMessage("PageLoader:LoadEvent", { sendAsyncMessage("PageLoader:LoadEvent", {
time: content.window.performance.now(), time: Date.now(), // eslint-disable-line
name: "tphero", name: "tphero",
}); });
obs.disconnect(); obs.disconnect();

View File

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from report.js */ /* import-globals-from report.js */
/* eslint mozilla/avoid-Date-timing: "off" */
var { AppConstants } = ChromeUtils.import( var { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm" "resource://gre/modules/AppConstants.jsm"
@ -408,7 +409,7 @@ function startAndLoadURI(pageName) {
TalosParentProfiler.resume("Starting to load URI " + pageName); TalosParentProfiler.resume("Starting to load URI " + pageName);
} }
start_time = window.performance.now(); start_time = Date.now();
if (loadNoCache) { if (loadNoCache) {
content.loadURI(pageName, { content.loadURI(pageName, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
@ -531,9 +532,9 @@ var plNextPage = async function() {
if (doNextPage) { if (doNextPage) {
if (forceCC) { if (forceCC) {
var tccstart = window.performance.now(); var tccstart = new Date();
window.windowUtils.garbageCollect(); window.windowUtils.garbageCollect();
var tccend = window.performance.now(); var tccend = new Date();
report.recordCCTime(tccend - tccstart); report.recordCCTime(tccend - tccstart);
// Now asynchronously trigger GC / CC in the content process // Now asynchronously trigger GC / CC in the content process
@ -732,7 +733,7 @@ function _loadHandlerCapturing() {
if (useMozAfterPaint) { if (useMozAfterPaint) {
if (gStartTime != null && gStartTime >= 0) { if (gStartTime != null && gStartTime >= 0) {
gTime = window.performance.now() - gStartTime; gTime = new Date() - gStartTime;
gStartTime = -1; gStartTime = -1;
} }
} }
@ -785,18 +786,9 @@ function _loadHandler(paint_time = 0) {
if (paint_time !== 0) { if (paint_time !== 0) {
// window.performance.timing.timeToNonBlankPaint is a timestamp // window.performance.timing.timeToNonBlankPaint is a timestamp
// this may have a value for hero element (also a timestamp) // this may have a value for hero element (also a timestamp)
end_time = paint_time;
let minDate = new Date("2001");
if (paint_time < minDate) {
//paint_time is a performance.now() value
end_time = paint_time;
} else {
//paint_time is a UNIX timestamp
end_time = paint_time - window.performance.timing.navigationStart;
}
} else { } else {
end_time = window.performance.now(); end_time = Date.now();
} }
var duration; var duration;
@ -851,7 +843,7 @@ function plLoadHandlerMessage(message) {
} }
if (gTime !== -1) { if (gTime !== -1) {
if (useMozAfterPaint && gStartTime >= 0) { if (useMozAfterPaint && gStartTime >= 0) {
time = window.performance.now() - gStartTime; time = Date.now() - gStartTime;
gStartTime = -1; gStartTime = -1;
} else if (!useMozAfterPaint) { } else if (!useMozAfterPaint) {
time = gTime; time = gTime;

View File

@ -90,7 +90,7 @@ Report.prototype.getReport = function() {
report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n"; report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n";
report += "__end_cc_report\n"; report += "__end_cc_report\n";
} }
var now = window.performance.now(); var now = new Date().getTime(); // eslint-disable-line mozilla/avoid-Date-timing
report += "__startTimestamp" + now + "__endTimestamp\n"; // timestamp for determning shutdown time, used by talos report += "__startTimestamp" + now + "__endTimestamp\n"; // timestamp for determning shutdown time, used by talos
return report; return report;

View File

@ -91,8 +91,8 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) {
resolve(); resolve();
}); });
imported.src = // eslint-disable-next-line mozilla/avoid-Date-timing
"../../scripts/talos-debug.js?dummy=" + win.performance.now(); // For some browsers to re-read imported.src = "../../scripts/talos-debug.js?dummy=" + Date.now(); // For some browsers to re-read
document.head.appendChild(imported); document.head.appendChild(imported);
return; return;
} }
@ -125,6 +125,12 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) {
}); });
} }
function myNow() {
return win.performance && win.performance.now
? win.performance.now()
: Date.now(); // eslint-disable-line mozilla/avoid-Date-timing
}
var isWindow = target.self === target; var isWindow = target.self === target;
var getPos = isWindow var getPos = isWindow
@ -185,13 +191,13 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) {
function P_syncScrollTest() { function P_syncScrollTest() {
return new Promise(function(resolve) { return new Promise(function(resolve) {
// We should be at the top of the page now. // We should be at the top of the page now.
var start = win.performance.now(); var start = myNow();
var lastScrollPos = getPos(); var lastScrollPos = getPos();
var lastScrollTime = start; var lastScrollTime = start;
var durations = []; var durations = [];
function tick() { function tick() {
var now = win.performance.now(); var now = myNow();
var duration = now - lastScrollTime; var duration = now - lastScrollTime;
lastScrollTime = now; lastScrollTime = now;

View File

@ -363,7 +363,7 @@ class BrowserLogResults(object):
self.error("Could not find %s in browser output: (tokens: %s)" self.error("Could not find %s in browser output: (tokens: %s)"
% (attr, tokens)) % (attr, tokens))
try: try:
value = int(float(value)) value = int(value)
except ValueError: except ValueError:
self.error("Could not cast %s to an integer: %s" self.error("Could not cast %s to an integer: %s"
% (attr, value)) % (attr, value))

View File

@ -122,13 +122,13 @@ this.sessionrestore = class extends ExtensionAPI {
? StartupPerformance.latestRestoredTimeStamp ? StartupPerformance.latestRestoredTimeStamp
: startup_info.sessionRestored; : startup_info.sessionRestored;
let duration = restoreTime - startup_info.process; let duration = restoreTime - startup_info.process;
let win = BrowserWindowTracker.getTopWindow();
// Report data to Talos, if possible. // Report data to Talos, if possible.
dump("__start_report" + duration + "__end_report\n\n"); dump("__start_report" + duration + "__end_report\n\n");
// Next one is required by the test harness but not used. // Next one is required by the test harness but not used.
dump("__startTimestamp" + win.performance.now() + "__endTimestamp\n\n"); // eslint-disable-next-line mozilla/avoid-Date-timing
dump("__startTimestamp" + Date.now() + "__endTimestamp\n\n");
} catch (ex) { } catch (ex) {
dump(`SessionRestoreTalosTest: error ${ex}\n`); dump(`SessionRestoreTalosTest: error ${ex}\n`);
dump(ex.stack); dump(ex.stack);

View File

@ -41,7 +41,6 @@ this.startup_about_home_paint = class extends ExtensionAPI {
async checkForTelemetry() { async checkForTelemetry() {
let snapshot = Services.telemetry.getSnapshotForScalars("main"); let snapshot = Services.telemetry.getSnapshotForScalars("main");
let measurement = snapshot.parent[SCALAR_KEY]; let measurement = snapshot.parent[SCALAR_KEY];
let win = BrowserWindowTracker.getTopWindow();
if (!measurement) { if (!measurement) {
if (gAttempts == MAX_ATTEMPTS) { if (gAttempts == MAX_ATTEMPTS) {
dump(`Failed to get ${SCALAR_KEY} scalar probe in time.\n`); dump(`Failed to get ${SCALAR_KEY} scalar probe in time.\n`);
@ -57,7 +56,8 @@ this.startup_about_home_paint = class extends ExtensionAPI {
} else { } else {
// Got our measurement. // Got our measurement.
dump("__start_report" + measurement + "__end_report\n\n"); dump("__start_report" + measurement + "__end_report\n\n");
dump("__startTimestamp" + win.performance.now() + "__endTimestamp\n"); // eslint-disable-next-line mozilla/avoid-Date-timing
dump("__startTimestamp" + Date.now() + "__endTimestamp\n");
let env = Cc["@mozilla.org/process/environment;1"].getService( let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment Ci.nsIEnvironment

View File

@ -48,7 +48,8 @@ function dumpConsoleAndQuit() {
// Close window asynchronously, there might still be startup operations that still need to run // Close window asynchronously, there might still be startup operations that still need to run
window.setTimeout(function() { window.setTimeout(function() {
if (window.dump) { if (window.dump) {
dump("__startTimestamp" + window.performance.now() + "__endTimestamp\n"); // eslint-disable-next-line mozilla/avoid-Date-timing
dump("__startTimestamp" + Date.now() + "__endTimestamp\n");
} }
TalosPowersContent.goQuitApplication(); TalosPowersContent.goQuitApplication();
}, 0); }, 0);

View File

@ -166,7 +166,8 @@ addEventListener(
let uniqueMessageId = let uniqueMessageId =
"TalosPowers:ParentExec:" + "TalosPowers:ParentExec:" +
content.document.documentURI + content.document.documentURI +
content.window.performance.now() + // eslint-disable-next-line mozilla/avoid-Date-timing
Date.now() +
Math.random(); Math.random();
// Listener for the reply from the parent process // Listener for the reply from the parent process

View File

@ -18,7 +18,7 @@
TalosContentProfiler.resume("dhtml test start", true).then(() => { TalosContentProfiler.resume("dhtml test start", true).then(() => {
var container = document.getElementById("container"); var container = document.getElementById("container");
var lastchild = document.getElementById("lastchild"); var lastchild = document.getElementById("lastchild");
var start = window.performance.now(); var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing
var i, div; var i, div;
for (i = 0; i < 2000; i++) { for (i = 0; i < 2000; i++) {
div = document.createElement("div"); div = document.createElement("div");
@ -44,8 +44,8 @@
} }
function postProcessingRecord(s) { function postProcessingRecord(s) {
// alert(window.performance.now() - s); // alert(new Date() - s);
let delta = window.performance.now() - s; let delta = new Date() - s; // eslint-disable-line mozilla/avoid-Date-timing
TalosContentProfiler.pause("dhtml test finish", true).then(() => { TalosContentProfiler.pause("dhtml test finish", true).then(() => {
tpRecordTime(delta, s); tpRecordTime(delta, s);
}); });

View File

@ -118,7 +118,7 @@ function mutateTable() {
ensureAccessibleTreeForId("start"); ensureAccessibleTreeForId("start");
TalosContentProfiler.resume("tablemutation start", true).then(() => { TalosContentProfiler.resume("tablemutation start", true).then(() => {
var start = window.performance.now(); var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing
// Cause all kinds of crazy events // Cause all kinds of crazy events
Range.deleteContents(); Range.deleteContents();
@ -131,8 +131,8 @@ function mutateTable() {
} }
function postProcessingRecord(s) { function postProcessingRecord(s) {
// alert(window.performance.now() - s); // alert(new Date() - s);
let delta = window.performance.now() - s; let delta = new Date() - s; // eslint-disable-line mozilla/avoid-Date-timing
TalosContentProfiler.pause("tablemutation finish", true).then(() => { TalosContentProfiler.pause("tablemutation finish", true).then(() => {
tpRecordTime(delta, s); tpRecordTime(delta, s);
}); });

View File

@ -30,11 +30,6 @@ ChromeUtils.defineModuleGetter(
"TalosParentProfiler", "TalosParentProfiler",
"resource://talos-powers/TalosParentProfiler.jsm" "resource://talos-powers/TalosParentProfiler.jsm"
); );
ChromeUtils.defineModuleGetter(
this,
"BrowserWindowTracker",
"resource:///modules/BrowserWindowTracker.jsm"
);
const REDUCE_MOTION_PREF = "ui.prefersReducedMotion"; const REDUCE_MOTION_PREF = "ui.prefersReducedMotion";
const MULTI_OPT_OUT_PREF = "dom.ipc.multiOptOut"; const MULTI_OPT_OUT_PREF = "dom.ipc.multiOptOut";
@ -133,17 +128,12 @@ this.tabpaint = class extends ExtensionAPI {
* with the time (in ms) it took to open the tab from the parent. * with the time (in ms) it took to open the tab from the parent.
*/ */
async openTabFromParent(gBrowser, target) { async openTabFromParent(gBrowser, target) {
let win = BrowserWindowTracker.getTopWindow();
TalosParentProfiler.resume("tabpaint parent start"); TalosParentProfiler.resume("tabpaint parent start");
gBrowser.selectedTab = gBrowser.addTab( // eslint-disable-next-line mozilla/avoid-Date-timing
//win.performance.now() + win.performance.timing.navigationStart gives the UNIX timestamp. gBrowser.selectedTab = gBrowser.addTab(`${target}?${Date.now()}`, {
`${target}?${win.performance.now() + triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
win.performance.timing.navigationStart}`, });
{
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
}
);
let { tab, delta } = await this.whenTabShown(); let { tab, delta } = await this.whenTabShown();
TalosParentProfiler.pause("tabpaint parent end"); TalosParentProfiler.pause("tabpaint parent end");

View File

@ -15,9 +15,7 @@ function init() {
window.addEventListener("TabPaint:OpenFromContent", (event) => { window.addEventListener("TabPaint:OpenFromContent", (event) => {
let target = document.getElementById("target"); let target = document.getElementById("target");
let now = Date.now(); // eslint-disable-line mozilla/avoid-Date-timing
//win.performance.now() + win.performance.timing.navigationStart gives the UNIX timestamp.
let now = window.performance.now() + window.performance.timing.navigationStart;
target.href = `${targetURL.href}?${now}`; target.href = `${targetURL.href}?${now}`;
target.click(); target.click();

View File

@ -30,10 +30,8 @@
} }
var uniqueMessageId = var uniqueMessageId =
TART_PREFIX + // eslint-disable-next-line mozilla/avoid-Date-timing
content.document.documentURI + TART_PREFIX + content.document.documentURI + Date.now() + Math.random();
content.window.performance.now() +
Math.random();
addMessageListener(TART_PREFIX + "chrome-exec-reply", function done( addMessageListener(TART_PREFIX + "chrome-exec-reply", function done(
reply reply

View File

@ -7,7 +7,8 @@
var uniqueMessageId = var uniqueMessageId =
TRESIZE_PREFIX + TRESIZE_PREFIX +
content.document.documentURI + content.document.documentURI +
content.window.performance.now() + // eslint-disable-next-line mozilla/avoid-Date-timing
Date.now() +
Math.random(); Math.random();
addMessageListener(TRESIZE_PREFIX + "chrome-run-reply", function done( addMessageListener(TRESIZE_PREFIX + "chrome-run-reply", function done(