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: reuse generalized clumping for perf category #9288

Closed
wants to merge 11 commits into from

Conversation

paulirish
Copy link
Member

I noticed that perf audits with warnings don't use the Passed audits but with warnings clump that @connorjclark added in #6989. Turns out most of the audits that can emit warnings are in perf and pwa, neither of which used the generalized clumping stuff in category-renderer.

This PR lets the perf cat use the clumping stuff. And makes sure we don't accidentally not render audits (which has been happening to User Timing for a while).

The major fix: any passed audits in perf category with warnings will be rendered in the pre-expanded clump for extra visibility.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -68,7 +68,17 @@ describe('PerfCategoryRenderer', () => {
it('renders the sections', () => {
const categoryDOM = renderer.render(category, sampleResults.categoryGroups);
const sections = categoryDOM.querySelectorAll('.lh-category > .lh-audit-group');
assert.equal(sections.length, 5);
const sectionTitles = Array.from(sections).map(el => el.className);
expect(sectionTitles).toMatchInlineSnapshot(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

😍

const passedAudits = category.auditRefs.filter(audit =>
audit.group && audit.group !== 'metrics' && audit.id !== 'performance-budget'
&& Util.showAsPassed(audit.result));
const passedAudits = category.auditRefs.filter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to passedAuditIds?

Copy link
Member

@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.

seems good to share the implementation

I noticed that perf audits with warnings don't use the Passed audits but with warnings clump that @connorjclark added in #6989.

can you add a test that those do get rendered with a warning now?

@@ -156,7 +156,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer {

// Filmstrip
const timelineEl = this.dom.createChildOf(element, 'div', 'lh-filmstrip-container');
const thumbnailAudit = category.auditRefs.find(audit => audit.id === 'screenshot-thumbnails');
const thumbnailAudit = category.auditRefs.find(audit => audit.group === 'filmstrip');
Copy link
Member

@brendankenny brendankenny Jun 27, 2019

Choose a reason for hiding this comment

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

this doesn't seem better since (here and below) the code really is looking for a particular audit, not whatever happens to be first in a group (or happens to be the only one in a group)?

const renderedAudits = [...metricAudits, thumbnailAudit, budgetAudit, ...opportunityAudits,
...diagnosticAudits];
const unrenderedAudits = category.auditRefs.filter(ref => !renderedAudits.includes(ref));
const remainingAudits = unrenderedAudits.filter(ref => !!ref.group);
Copy link
Member

@brendankenny brendankenny Jun 27, 2019

Choose a reason for hiding this comment

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

this seems like it'll be easy to forget to add things to the renderedAudits list and get them rendered twice.

What if we switched how we do the non-rendered audits and gave them an explicit group (report-invisible or a name equally as good) instead of no group?

It would reduce the mystery of how the audits that don't show up in the html report work and let this check just be whatever hasn't been rendered yet and isn't in that group.

Copy link
Member Author

Choose a reason for hiding this comment

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

this sounds good.

it means every auditRef needs a group. but that works for me.

the tricky thing is manual audits are currently defined by their scoreDisplayMode, and this should be a group.

but once that's cleaned up it makes sense to do that policy change.

lighthouse-core/report/html/renderer/category-renderer.js Outdated Show resolved Hide resolved
lighthouse-core/report/html/renderer/category-renderer.js Outdated Show resolved Hide resolved
lighthouse-core/report/html/renderer/category-renderer.js Outdated Show resolved Hide resolved
lighthouse-core/report/html/renderer/category-renderer.js Outdated Show resolved Hide resolved
* @param {LH.Result.Category.manualDescription} [manualDescription]
* @return {Element[]}
*/
_splitAndRenderClumps(auditRefs, groupDefinitions = {}, manualDescription) {
Copy link
Member

Choose a reason for hiding this comment

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

doesn't the leading underscore still break when rolling to devtools (closure won't like perf-category-rendering trying to access it outside of this file?).

It's also pretty much what render() was before, so having it as a public method feels as ok as renderAuditGroup, renderClump, etc, so I say just go for

Suggested change
_splitAndRenderClumps(auditRefs, groupDefinitions = {}, manualDescription) {
renderClumps(auditRefs, groupDefinitions, manualDescription) {

Copy link
Member

Choose a reason for hiding this comment

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

also should move the really good ascii diagram + description to this method as this is the one actually doing it now

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

const renderedAudits = [...metricAudits, thumbnailAudit, budgetAudit, ...opportunityAudits,
...diagnosticAudits];
const unrenderedAudits = category.auditRefs.filter(ref => !renderedAudits.includes(ref));
const remainingAudits = unrenderedAudits.filter(ref => !!ref.group);
Copy link
Member Author

Choose a reason for hiding this comment

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

this sounds good.

it means every auditRef needs a group. but that works for me.

the tricky thing is manual audits are currently defined by their scoreDisplayMode, and this should be a group.

but once that's cleaned up it makes sense to do that policy change.

* @param {Object<string, LH.Result.ReportGroup>} [groupDefinitions]
* @return {Element}
*/
render(category, groupDefinitions = {}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

(the diff is a little funny here because i moved the diagram... but the method signature and top 3 lines are identical to what it had been.)

git diff catches the changes as a "move", and calls out the new method of renderClumps a bit more clearer

image

const filmstripEl = this.detailsRenderer.render(thumbnailResult.details);
filmstripEl && timelineEl.appendChild(filmstripEl);
// We only expect one of these, but the renderer will support multiple
const thumbnailAudits = category.auditRefs.filter(audit => audit.group === 'filmstrip');
Copy link
Collaborator

@connorjclark connorjclark Sep 21, 2020

Choose a reason for hiding this comment

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

Is this breaking? v7? or: support as fallback the old way.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this would break formatting the v6 reports in a new renderer. good call. i'll add a compat bit to also the screenshot-thumbnails audit

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

unsure if breaking change

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