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

report: add full-page-screenshot to experimental config #10716

Merged
merged 166 commits into from
Jul 20, 2020
Merged

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented May 6, 2020

demo

image
image

Summary

New gatherer: full-page-screenshot changes the screen emulation to be as large as the content height and snaps a JPEG, backing off as necessary to meet size thresholds. After: if Lighthouse is in control of the emulation, we easily set it back to the emulated state. Otherwise, if emulation is outside of our control, we do our best to put it back. In practice this probably doesn't matter, since this is the afterPass of the very last gatherer, and we'd expect any programatic usage of Lighthouse to not reuse the page after the LH run.

New details: for the node detail type, an optional boundingRect represents the location of the node on the screen.

New audit: full-page-screenshot, simply exposes the FullPageScreenshot artifact.

New renderer: element-screenshot-renderer, for node details with a boundingRect, display a clipped image of the full page screenshot. On click, use the same renderer to paint the clipped image in a larger viewport in an overlay. The overlay is enabled in report-ui-features.


old

(before many refactors)

emulation

The previous PR wired emulation overrides through the driver + emulation files. Instead, I moved the presets out of emulation.js and into driver.js, meaning the overrides only go to Driver.beginEmulation. I think moving presets out of emulation.js makes the file better encapsulated.

on click

currently if you click on a node image you'll get a shadowbox overlay over the entire report. I see there is some code for instead showing the image in the corner of the page. I suppose we could also do a tooltip hover thing. We should sort out exactly what we want to do.

size

I added a script json-sizes so we can get a feel for how much larger this will make the LHR.

cat lhr.json | jq .audits | node lighthouse-core/scripts/json-size.js

theverge.com:

total                              100	897127
full-page-screenshot               38	337865
network-requests                   27	239008
screenshot-thumbnails              11	96481
final-screenshot                   4	37873
uses-long-cache-ttl                4	36034
tap-targets                        2	13667
network-server-latency             1	13084
network-rtt                        1	10443
third-party-summary                1	10294
uses-rel-preconnect                1	8864
bootup-time                        1	6958
unused-javascript                  1	6323
user-timings                       0	3702
...snip...

example.com:

total                              100	155237
screenshot-thumbnails              43	66273
final-screenshot                   10	15533
full-page-screenshot               9	13700
resource-summary                   1	1278
metrics                            1	1231
network-requests                   1	1210
mainthread-work-breakdown          1	1069
dom-size                           1	1006
html-has-lang                      1	969
critical-request-chains            1	946
bootup-time                        1	848
font-size                          0	739
...snip...

Cont: #8797

Note: do not use "land when green". Add Co-authored-by: Matt Zeunert <[email protected]> to commit body.

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.

spent some time in the renderer. in general it's dealing with the complexity quite well. :)

the var names make reading it a little tough so i have a few suggestions below that should help (and shouldn't be too contentious)

i'm also gonna do a followup PR with a slightly more contentious naming tweak

* @param {LH.Artifacts.Rect} elementRectInScreenshotCoords
* @param {Size} elementPreviewSizeInScreenshotCoords
*/
static renderClipPath(dom, maskEl, positionClip,
Copy link
Member

Choose a reason for hiding this comment

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

I believe we can simplify this, but I'll attempt it in a followup.

markerEl.style.top = positions.clip.top * zoomFactor + 'px';

const maskEl = dom.find('.lh-element-screenshot__mask', containerEl);
maskEl.style.width = elementPreviewSizeInDisplayCoords.width + 'px';
Copy link
Member

Choose a reason for hiding this comment

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

on my 2dpr screen i see a 1px edge on the right where the mask doesn't extend. not sure why, though.

image

not a blocker for shipping, obv.

This comment was marked as spam.

* @param {Size} elementPreviewSizeInScreenshotCoords
* @param {Size} screenshotSize
*/
static getScreenshotPositions(elementRectInScreenshotCoords,
Copy link
Member

Choose a reason for hiding this comment

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

since this method is clearly working in screenshot coordinate scale, can we drop InScreenshotCoords from all the var names within?

Copy link
Collaborator

@patrickhulce patrickhulce Jul 18, 2020

Choose a reason for hiding this comment

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

I would like to push back a little on the idea that anything anywhere here is clearly working in any particular scale :)

it's definitely clearer what's happening within this function but in absence of comments getScreenshotPositions could easily be a name for a function that returns somethingScreenshotCords based on somethingDisplayCoords.

in my experience variable names are less easily ignored when reading a function to figure out what it's doing than function overview. I'm ok with removing the suffix, just didn't want it to die without a fight :)

Copy link
Member

@paulirish paulirish Jul 18, 2020

Choose a reason for hiding this comment

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

aiight well if you're already feelin this, lemme pitch you on what I was going to put in a separate PR. basically abbreviating all the suffixes:

  • elementRectInScreenshotCoords => elementRect_SC
  • maxRenderSizeInDisplayCoords => maxRenderSize_DC

On my first pass looking at this renderer code i was really confused because the var names suffix was "Coords" but their types were Rect/Size. But then realized the different coords spaces and i'm pleased the names indicate this signal. But still, it just takes up so much visual space that I think it current hampers readability.

So yeah. suffix abbreviation. Connor's on board. so if you're into it, we could just do this.

edit: (Oh last bit... I already wrote a lil description for the top.. and we'd add in the abbv's in thar:

/**
 * @overview These functions define {Rect}s and {Size}s using two different coordinate spaces:
 *   1. Screenshot coords (SC): where 0,0 is the top left of the screenshot image
 *   2. Display coords (DC): that match the CSS pixel coordinate space of the LH report's page.
 */

)

Copy link
Collaborator

Choose a reason for hiding this comment

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

this plus the fileoverview explaining the two coordinate spaces (and what the abbreviation means) SGTM 👍

Copy link
Member

Choose a reason for hiding this comment

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

Just no underscores, please :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So yeah. suffix abbreviation. Connor's on board. so if you're into it, we could just do this.

plz do this in followup pr

@connorjclark connorjclark dismissed brendankenny’s stale review July 20, 2020 16:04

addressed review by moving to experimental config

@connorjclark connorjclark changed the title report: add full-page element screenshot to experimental config report: add full-page-screenshot to experimental config Jul 20, 2020
@connorjclark connorjclark merged commit 3efbf94 into master Jul 20, 2020
@connorjclark connorjclark deleted the elscreens branch July 20, 2020 18:06
@connorjclark connorjclark mentioned this pull request Mar 10, 2021
16 tasks
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.