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

new_audit: layout-shifts with estimated root causes #15703

Merged
merged 45 commits into from
Jan 4, 2024

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Dec 19, 2023

Builds off of #15702

Introduces layout-shifts, an audit similar to layout-shift-elements but focused on shifts instead of individually impacted nodes. Additionally, makes use of the CLS root causes from the shared trace engine, and creates sub items if any possible root cause is found for a given shift.

Doc.

outdated example report

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 file will be deleted whenever we properly move the shared trace engine to a separate repository, with properly emitted types. Or maybe we can get that while it still lives in CDT. I haven't investigated the problem yet, but it was fast enough to just copy/paste 95% of the types and hand write the little we really need so far.

Base automatically changed from shared-trace-engine-cls-calc to main December 19, 2023 21:26
@connorjclark connorjclark changed the title core(cumulative-layout-shift): calculate with shared trace engine core(layout_shifts): new_audit Dec 19, 2023
@connorjclark connorjclark marked this pull request as ready for review December 19, 2023 22:20
@connorjclark connorjclark requested a review from a team as a code owner December 19, 2023 22:20
@connorjclark connorjclark requested review from adamraine and removed request for a team December 19, 2023 22:20
@connorjclark connorjclark changed the title core(layout_shifts): new_audit new_audit: layout-shifts with estimated root causes Dec 19, 2023
const TraceHandlers = TraceEngine.Handlers.ModelHandlers;
/** @type {import('../../types/trace-engine.js').RootCauses & typeof import('../../types/trace-engine.js').RootCauses} */
const RootCauses = TraceEngine.RootCauses.RootCauses.RootCauses;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@paulirish this is what i did for the types for now

@connorjclark
Copy link
Collaborator Author

Quite lost on how this could have changed unminified-css/unused-css-rules (byte-efficiency smoke failing)

Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Can you add a image and/or example report?


const UIStrings = {
/** Descriptive title of a diagnostic audit that provides the top elements affected by layout shifts. */
title: 'Avoid large layout shifts',
Copy link
Member

Choose a reason for hiding this comment

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

This is the same title as layout-shift-elements. I understand why since the call to action is the same, but this makes me wonder if we should somehow combine the audits (e.g. multiple tables in the same audit)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the linked doc, we left the fate of this other audit unresolved: We should make it hidden or remove it or make it informative….

wdyt of marking it informative?

can also change title to Avoid large layout shifts (impacted elements)

Copy link
Member

Choose a reason for hiding this comment

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

I think I'm leaning towards the hide/remove option at this point. This new audit seems generally better than the old one and less of an information dump. That being said, if we still see value in the element summary my preferences go as follows:

  1. Hide/remove the old audit
  2. Add a second table to the new layout-shifts audit that takes the elements from the old audit
  3. Make the old audit informative

Copy link
Member

Choose a reason for hiding this comment

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

+1 to ditching the old one if possible (hidden for now to not break anyone makes sense). Is it possible to make sure all the information in the old audit is in the new audit (either improved or at least as-is)? e.g. for shifts without a known root cause

Copy link
Collaborator Author

@connorjclark connorjclark Dec 20, 2023

Choose a reason for hiding this comment

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

OK, let's hide it.

Is it possible to make sure all the information in the old audit is in the new audit (either improved or at least as-is)?

This audit won't hide a layout shift if it has no determined root cause. root cause is just an enhancement.

For the top 15 layout shifts, we'll show the the largest impacted element that moves in each shift, whereas the previous audit would show the top impacted elements despite being from the same shift or not. So it isn't 1:1, but we'll be showing all the biggest impacted nodes still. Should be higher useful info : noise ratio

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sorry, I commented without reading through the code or trying it out :) Sounds great to me!

core/audits/layout-shifts.js Show resolved Hide resolved
core/audits/layout-shifts.js Outdated Show resolved Hide resolved
core/audits/layout-shifts.js Show resolved Hide resolved
core/audits/layout-shifts.js Outdated Show resolved Hide resolved
Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Would also like to resolve #15703 (comment)

@connorjclark
Copy link
Collaborator Author

The failing test is flaky and unrelated: #15729

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