-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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(driver): wait for critical network requests #11738
Conversation
lighthouse-cli/test/smokehouse/test-definitions/tricky-metrics/expectations.js
Outdated
Show resolved
Hide resolved
@@ -112,10 +113,10 @@ function waitForFcp(session, pauseAfterFcpMs, maxWaitForFcpMs) { | |||
* `networkQuietThresholdMs` ms and a method to cancel internal network listeners/timeout. | |||
* @param {LH.Gatherer.FRProtocolSession} session | |||
* @param {NetworkRecorder} networkMonitor |
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.
(nit unrelated to PR) any reason this isn't called networkRecorder
?
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.
just an artifact of how it used to be in driver, though honestly networkMonitor
does better express it's usage almost everywhere other than for devtoolsLog creation :)
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.
it always confused me b/c there is no network-monitor file. would be nice to rename one or the other
return {promise, cancel: mockCancelFn}; | ||
}); | ||
|
||
return Object.assign(mockFn, {waitForCalls: calls}); |
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.
👀
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.
if these eyes are for preferring {...
that won't work for prototype/class properties of the jest mock fn :)
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.
ah ya I know. I was just eying the rare case where my blanket "use spread!" doesn't work :)
Summary
Waits for all critical (high priority) network requests to finish before continuing to the CPU idle check. This solves the issue when the entire page is gated on a single XHR but we move on because we're already at network 2-quiet. This also addresses the problem where the LCP image is very large and added via script where we optimistically report the LCP too early.
The net effect here will be Lighthouse taking a little longer for each run and performance scores dipping as more resources and more CPU work is included in our observations. The net effect on popular sites I tried that don't face the failure case was relatively small. The smoketest and URLs in the linked issues illustrate the massive failure cases we're addressing.
Related Issues/PRs
fixes #11180
fixes #10810
fixes #11639