Skip to content
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

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Dec 1, 2020

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.

  • CNN, waits an additional ~1s, no observable effect on scores
  • The Verge, waits an additional ~2s, no observable effect on scores
  • ESPN, waits an additional ~1s, no observable effect on scores

Related Issues/PRs
fixes #11180
fixes #10810
fixes #11639

@@ -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
Copy link
Collaborator

@connorjclark connorjclark Dec 7, 2020

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?

Copy link
Collaborator Author

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 :)

Copy link
Collaborator

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});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Collaborator Author

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 :)

Copy link
Collaborator

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants