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(full-page-screenshot): get screenshot, nodes concurrently #14763

Merged
merged 2 commits into from Feb 8, 2023

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Feb 8, 2023

This change seems to resolve an issue where sometimes LH would produce element screenshots that did not line up (test w/ cnn.com). It was flaky behavior, so it's hard to know for sure if this is truly solved now. Please run a few times yourself. The list audit in a11y is what I was checking. If user-sync file is downloaded, trash the run and try again.

I ran this patch roughly 20 times with no incident, whereas before I could reproduce this problem at least twice every 5 runs.

@connorjclark connorjclark requested a review from a team as a code owner February 8, 2023 00:08
@connorjclark connorjclark requested review from adamraine and removed request for a team February 8, 2023 00:08
@@ -222,9 +222,11 @@ class FullPageScreenshot extends FRGatherer {
await this._resizeViewport(context, deviceMetrics);
}

const [screenshot, nodes] =
await Promise.all([this._takeScreenshot(context), this._resolveNodes(context)]);
Copy link
Member

Choose a reason for hiding this comment

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

should include a comment, otherwise this appears unnecessary

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

I looked at the CDP activity here and this change looks good

(i bet if we just swapped the order of the two original lines, it'd be mostly equivalent. but.. this is fine.)

the screenshot has extra latency in encoding. we don't want to delay collecting nodes while waiting for the webp encoder... here's the cdp activity with the PR applied

image (70)

you can see the search highlight in the scrollbar for where the screenshot comes back. according to the debug timestamps, the screenshot artifact took 2s to collect.

for added bonus we could make the two resolveNodesInPage in parallel.

@brendankenny
Copy link
Member

for added bonus we could make the two resolveNodesInPage in parallel.

This brings up a good point for maintenance: all it takes is some future change putting an async call ahead of Page.captureScreenshot in _takeScreenshot and this careful ordering can be broken again (a test could be interesting, but it would be flakey when failing, so I don't know how effective/annoying that would be :).

I don't think it's necessary to land this change since we want it for 10.0, but it probably makes sense to merge _takeScreenshot and _resolveNodes so that the individual protocol calls can be ordered and scheduled directly.

@connorjclark
Copy link
Collaborator Author

Thanks for digging in @paulirish. I spent so long bisecting (to no avail) and on a whim thought to try this small change and was happy it worked out, but in the interest of time just wanted to move on. I opened #14764 to track the additional work here.

@connorjclark connorjclark changed the title core(full-page-screenshot): collect screenshots and nodes concurrently core(full-page-screenshot): get screenshot and nodes concurrently Feb 8, 2023
@connorjclark connorjclark changed the title core(full-page-screenshot): get screenshot and nodes concurrently core(full-page-screenshot): get screenshot, nodes concurrently Feb 8, 2023
@connorjclark connorjclark merged commit 8a1e84f into main Feb 8, 2023
@connorjclark connorjclark deleted the fix-fps-sometimes-off branch February 8, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants