-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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(installable-manifest): check for fetchable icon #10168
Conversation
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.
my biggest concern about this is that we could be fetching lots of files very slowing for not a ton of benefit... (especially in WPT-like environments that are throttled outside of our control)
what are thoughts on just fetching the largest icon to check and/or whatever one chrome is most likely to actually use?
// Add a warning for icons that aren't fetchable. | ||
if (manifest.value && Array.isArray(manifest.value.icons.value)) { | ||
const iconsToFetch = manifest.value.icons.value | ||
.filter(icon => icon.value.src && icon.value.src.value); |
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.
were empty string icons treated as acceptable before but now they won't be? or I suppose they will be valid because we won't try to fetch and put any warning on them?
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.
at this point empty strings were converted to undefined
(see parser). later, the icons check will ignore icons whose src
does not end in .png
.
... however I've just noticed there's a bug if typeHint === 'image/png'
and src
is undefined. this is so dirty. Can fix by tweaking getFetchableIcons
to also check for a nonempty string.
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.
aight sgtm
${JSON.stringify(icon.value.src.value)} | ||
)`; | ||
if (!await passContext.driver.evaluateAsync(expression, {useIsolation: true})) { | ||
icon.warning = 'Error fetching icon'; |
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.
don't love the Promise.all mutating an object, can we make this a map of the icon results?
const expression = `(${pageFunctions.fetchIsOkString})( | ||
${JSON.stringify(icon.value.src.value)} | ||
)`; | ||
if (!await passContext.driver.evaluateAsync(expression, {useIsolation: true})) { |
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.
Feels like we should make this timeout very short and .catch
them to not be a fatal protocol timeout
@@ -36,6 +36,17 @@ describe('Icons helper', () => { | |||
assert.equal(icons.doExist(manifest.value), false); | |||
}); | |||
|
|||
it('fails when a manifest contains no fetchable icons', () => { |
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.
ooo ooo can we get an empty string test in here before we forget about it again :D
Only attempt the largest, or attempt all above |
Ideally, we'd do whatever browsers are most likely to do across all users. i.e. if Chrome will try the 512 icon first and use it if it works we do the same, try to fetch 512 and stop if it worked |
Here is the installation check. Just looks for any icon >= 144px (with a caveat for maskable icons that #10197 will no doubt need to consider). No fetch here. More complicated logic is done to determine the best fitting icon. Rather than replicating that, we should just let Chrome do the fetching and sniff for the error it may create. |
oh right, I forgot about this #8995 should be fine to use this protocol for just the signal for failure to fetch an icon. |
fyi: part 2 of the getInstallabilityErrors -- tweaks to frontend: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2016235 |
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
The parser code style is different because we forked it from an existing library, and at the time we didn't know what we'd actually need out of it, so the output is just the direct tree instead of linearized errors or whatever. If there are actual bugs to report we should fix them, we should rely on the protocol when we can do so, but in the meantime let's not unnecessarily antagonize those of us that had to do the library forking :) |
@@ -115,15 +115,18 @@ describe('ReportRenderer', () => { | |||
const container = renderer._dom._document.body; | |||
const output = renderer.renderReport(sampleResultsCopy, container); | |||
|
|||
function isPWAGauge(el) { |
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.
pwa category is failing for the sample report json now, which means the pwa__wrapper class isn't set. Changed the test to look at text content instead.
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 well I had to update the sample artifacts anyways, but I'm gonna keep this test change.
proto/sample_v2_round_trip.json
Outdated
@@ -2028,7 +2028,7 @@ | |||
"vulnCount": 2.0 | |||
} | |||
], | |||
"summary": {}, |
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.
why have these changed?
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.
because i forgot to edit them back
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.
i havent update proto ..
@connorjclark the assignment was just to reflect our new policy right, you're not waiting on me? I don't see anything objectionable that's new so my approval still stands |
I think how Lighthouse deals with manifests could be improved, but that's a pretty big project for small gain. This PR does the minimal necessary to fix #789.