Bug 1451460 - Switch to using MozLayerTreeReady in the parent process to know when to stop the TPS stopwatch. r?rwood
MozLayerTreeReady is fired once the parent process hears from the compositor that the layers
from a remote tab have been painted and uploaded. For tab switching, this is a far more accurate
assessment of when the tab is actually presented to the user, since this is the event that the
async tab switcher also listens for.
MozReview-Commit-ID: 8oy5MqNwWNS
--- a/testing/talos/talos/tests/tabswitch/api.js
+++ b/testing/talos/talos/tests/tabswitch/api.js
@@ -150,20 +150,19 @@ function loadTPSContentScript(browser) {
/**
* For some <xul:tab> in a browser window, have that window switch
* to that tab. Returns a Promise that resolves ones the tab content
* has been presented to the user.
*/
async function switchToTab(tab) {
let browser = tab.linkedBrowser;
let gBrowser = tab.ownerGlobal.gBrowser;
- let window = tab.ownerGlobal;
await loadTPSContentScript(browser);
- let start = Math.floor(window.performance.timing.navigationStart + window.performance.now());
+ let start = Cu.now();
// We need to wait for the TabSwitchDone event to make sure
// that the async tab switcher has shut itself down.
let switchDone = waitForTabSwitchDone(browser);
// Set up our promise that will wait for the content to be
// presented.
let finishPromise = waitForContentPresented(browser);
// Finally, do the tab switch.
@@ -203,21 +202,21 @@ function waitForTabSwitchDone(browser) {
*
* @returns Promise
* Resolves once the content has been presented. Resolves to
* the system time that the presentation occurred at, in
* milliseconds since midnight 01 January, 1970 UTC.
*/
function waitForContentPresented(browser) {
return new Promise((resolve) => {
- let mm = browser.messageManager;
- mm.addMessageListener("TPS:ContentSawPaint", function onContentPaint(msg) {
- mm.removeMessageListener("TPS:ContentSawPaint", onContentPaint);
- resolve(msg.data.time);
- });
+ browser.addEventListener("MozLayerTreeReady", function onLayersReady(event) {
+ let now = Cu.now();
+ TalosParentProfiler.mark("MozLayerTreeReady seen by tps");
+ resolve(now);
+ }, { once: true });
});
}
/**
* Given some browser, do a garbage collect in the parent, and then
* a garbage collection in the content process that the browser is
* running in.
*