Skip to content

Conversation

@connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Oct 6, 2021

fixes #12923

  • Replaces thumbnail detail types in all audits with node
  • Skip rendering of nodeLabel and snippet if tagName is img and is visible (not a tracking pixel...)

EDIT: images are a tad old: now they all show HTML snippets. will hide in some cases in a followup PR. see #13185 (comment)

image
image
image
image

@connorjclark connorjclark requested a review from a team as a code owner October 6, 2021 23:27
@connorjclark connorjclark requested review from adamraine and removed request for a team October 6, 2021 23:27
@google-cla google-cla bot added the cla: yes label Oct 6, 2021
const isCrossOrigin = !URL.originsMatch(pageURL, image.url);

items.push({
node: imageElement ? Audit.makeNodeItem(imageElement.node) : undefined,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this and uses-optimized-images are the only image audits we have that can have an undefined node, because they iterate over OptimizedImages and use its url to look up a ImageElementOptimizedImages is gatherered from networkRecords, and ImageElements are gathered from querying the DOM (it also includes css images).

AFAICT, there should only ever be no ImageElement for an associated OptimizedImage if JS is used to download an image without ever adding it to the DOM. In that case, there's nothing to show via our full page screenshot. Should we fallback to the thumbnail in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fallback to the thumbnail in that case?

Is this possible without changing the display option for the entire column?

Copy link
Contributor

@brendankenny brendankenny Oct 12, 2021

Choose a reason for hiding this comment

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

Should we fallback to the thumbnail in that case?

Is this possible without changing the display option for the entire column?

Yeah, the individual item can set its own type, overriding the column type.

One problem with falling back to thumbnail, though, is it would still run into issues with hot linking/CSP/mixed-content warnings, so it's not clear we can do that.

really bad, terrible idea: should we attempt to take data url versions of important images that have 0-sized area in the full page screenshot and include them in the LHR if they're super important? like an LCP element that was removed by the time we took the screenshot.

const resultsMap = images.reduce((results, image) => {
/** @type {Map<string, WasteResult>} */
const resultsMap = new Map();
for (const image of images) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

drive by unreduce

const isCrossOrigin = !URL.originsMatch(pageURL, image.url);

items.push({
node: imageElement ? Audit.makeNodeItem(imageElement.node) : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fallback to the thumbnail in that case?

Is this possible without changing the display option for the entire column?

Comment on lines 498 to 503
// We use `node` to show images in the report withhout hotlinking. In that case,
// we don't want to show the html alongside the node thumbnail, as that information
// is likely not useful and just adds noise.
const hasVisibleBoundingRect = item.boundingRect &&
item.boundingRect.width > 1 && item.boundingRect.height > 1;
const shouldHideSnippetAndLabel = tagName === 'IMG' && hasVisibleBoundingRect;
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes for a closer match for the existing thumbnail behavior, but seems like we wouldn't want to drop these for some existing audits that may have <img> nodes (e.g. accessibility audits)?

also needs some tests :)

Copy link
Collaborator Author

@connorjclark connorjclark Oct 12, 2021

Choose a reason for hiding this comment

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

How would you suggest choosing when to elide this? It's pretty noisy when not needed. Gimme a minute and I'll put up a sample report.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure :/

A brute force approach would be the audit could just strip out the snippet and label in its own details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That could work. Audit.makeNodeItem could have an option to replace those values with empty strings.

I'll remove this eliding for now, and we can handle this in a followup PR.

@connorjclark connorjclark added 9.0 and removed breaking labels Oct 12, 2021
@connorjclark
Copy link
Collaborator Author

Should be good to merge, any last thoughts?

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Remove image hotlinking from report

5 participants