-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: don't load blank page twice in first pass #6369
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,22 +26,22 @@ const Driver = require('../gather/driver.js'); // eslint-disable-line no-unused- | |
* Execution sequence when GatherRunner.run() is called: | ||
* | ||
* 1. Setup | ||
* A. navigate to about:blank | ||
* B. driver.connect() | ||
* C. GatherRunner.setupDriver() | ||
* i. assertNoSameOriginServiceWorkerClients | ||
* ii. beginEmulation | ||
* iii. enableRuntimeEvents | ||
* iv. evaluateScriptOnLoad rescue native Promise from potential polyfill | ||
* v. register a performance observer | ||
* vi. register dialog dismisser | ||
* vii. clearDataForOrigin | ||
* i. navigate to a blank page | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove line |
||
* ii. assertNoSameOriginServiceWorkerClients | ||
* iii. retrieve and save userAgent | ||
* iv. beginEmulation | ||
* v. enableRuntimeEvents | ||
* vi. evaluateScriptOnLoad rescue native Promise from potential polyfill | ||
* vii. register a performance observer | ||
* viii. register dialog dismisser | ||
* iv. clearDataForOrigin | ||
* | ||
* 2. For each pass in the config: | ||
* A. GatherRunner.beforePass() | ||
* i. navigate to about:blank | ||
* ii. Enable network request blocking for specified patterns | ||
* iii. all gatherers' beforePass() | ||
* i. Enable network request blocking for specified patterns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still need |
||
* ii. all gatherers' beforePass() | ||
* B. GatherRunner.pass() | ||
* i. cleanBrowserCaches() (if it's a perf run) | ||
* ii. beginDevtoolsLog() | ||
|
@@ -105,7 +105,9 @@ class GatherRunner { | |
static async setupDriver(driver, options) { | ||
log.log('status', 'Initializing…'); | ||
const resetStorage = !options.settings.disableStorageReset; | ||
// Enable emulation based on settings | ||
// In the devtools/extension case, we can't still be on the site while trying to clear state | ||
// So we first navigate to a blank page, then apply our emulation & setup | ||
await GatherRunner.loadBlank(driver); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this use the config for the first pass (for blank page and duration)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah, I think @paulirish was even borderline on the way to removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused, aren't we still loading blank twice now? Seems like this line should go away and the comments moved into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry if I confused you with my "two blank calls" comment I meant for the pass and for before setup driver, not for setup driver + before setup driver :) |
||
await driver.assertNoSameOriginServiceWorkerClients(options.requestedUrl); | ||
await driver.beginEmulation(options.settings); | ||
await driver.enableRuntimeEvents(); | ||
|
@@ -176,7 +178,7 @@ class GatherRunner { | |
} | ||
|
||
/** | ||
* Navigates to about:blank and calls beforePass() on gatherers before tracing | ||
* Calls beforePass() on gatherers before tracing | ||
* has started and before navigation to the target page. | ||
* @param {LH.Gatherer.PassContext} passContext | ||
* @param {Partial<GathererResults>} gathererResults | ||
|
@@ -185,9 +187,7 @@ class GatherRunner { | |
static async beforePass(passContext, gathererResults) { | ||
const blockedUrls = (passContext.passConfig.blockedUrlPatterns || []) | ||
.concat(passContext.settings.blockedUrlPatterns || []); | ||
const blankPage = passContext.passConfig.blankPage; | ||
const blankDuration = passContext.passConfig.blankDuration; | ||
await GatherRunner.loadBlank(passContext.driver, blankPage, blankDuration); | ||
|
||
// Set request blocking before any network activity | ||
// No "clearing" is done at the end of the pass since blockUrlPatterns([]) will unset all if | ||
// neccessary at the beginning of the next pass. | ||
|
@@ -394,12 +394,11 @@ class GatherRunner { | |
try { | ||
await driver.connect(); | ||
const baseArtifacts = await GatherRunner.getBaseArtifacts(options); | ||
await GatherRunner.loadBlank(driver); | ||
baseArtifacts.BenchmarkIndex = await options.driver.getBenchmarkIndex(); | ||
await GatherRunner.setupDriver(driver, options); | ||
baseArtifacts.BenchmarkIndex = await options.driver.getBenchmarkIndex(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait I take it back this won't work sorry!! :) It needs to go before we setup emulation since its purpose is establishing the right multiplier (see #6162) it doesn't seem like it'd be the end of the world to have the two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to restoring the original There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
// Run each pass | ||
let firstPass = true; | ||
let isFirstPass = true; | ||
for (const passConfig of passes) { | ||
const passContext = { | ||
driver: options.driver, | ||
|
@@ -412,6 +411,10 @@ class GatherRunner { | |
}; | ||
|
||
await driver.setThrottling(options.settings, passConfig); | ||
if (!isFirstPass) { | ||
// Already on blank page if driver was just set up. | ||
await GatherRunner.loadBlank(driver, passConfig.blankPage, passConfig.blankDuration); | ||
} | ||
await GatherRunner.beforePass(passContext, gathererResults); | ||
await GatherRunner.pass(passContext, gathererResults); | ||
const passData = await GatherRunner.afterPass(passContext, gathererResults); | ||
|
@@ -434,10 +437,10 @@ class GatherRunner { | |
baseArtifacts.traces[passConfig.passName] = passData.trace; | ||
} | ||
|
||
if (firstPass) { | ||
if (isFirstPass) { | ||
// Copy redirected URL to artifact in the first pass only. | ||
baseArtifacts.URL.finalUrl = passContext.url; | ||
firstPass = false; | ||
isFirstPass = false; | ||
} | ||
} | ||
const resetStorage = !options.settings.disableStorageReset; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is now