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

core(responsiveness): use new EventTiming trace event format #13979

Merged
merged 4 commits into from
May 9, 2022

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented May 9, 2022

part of #13916

https://crrev.com/c/3632661 added a whole bunch of useful information to the EventTiming trace events, and this PR updates the responsiveness computed artifact to use them.

The computed artifact now returns the interaction event because that's where all the truly useful timing is, and in follow up PRs it will allow the actionability audit and the TraceElements gatherer to both use that information without having to figure it out from the Responsiveness event themselves.

This also means the metric will use the timing that matches the interaction breakdown, which sometimes differs by up to 4ms from the Responsiveness.Renderer.UserInteraction maxDuration. Ideally we can fix this difference upstream so that the trace events always match in duration.

Also updates timespan-responsiveness-m103.trace.json to get the latest trace event format.

@brendankenny brendankenny requested a review from a team as a code owner May 9, 2022 18:23
@brendankenny brendankenny requested review from adamraine and removed request for a team May 9, 2022 18:23
@brendankenny brendankenny mentioned this pull request May 9, 2022
30 tasks
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.

Seems like the only change visible in 9.6.0 would be the metric timing is different being off by a rounding error. Would it make more sense to exclude this from the cherry pick?

trace,
settings: {throttlingMethod: 'provided'},
};
expect(Responsiveness.request(metricInputData, {computedCache: new Map()}))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(Responsiveness.request(metricInputData, {computedCache: new Map()}))
await expect(Responsiveness.request(metricInputData, {computedCache: new Map()}))
  • other calls like this in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, thanks!

@brendankenny
Copy link
Member Author

Seems like the only change visible in 9.6.0 would be the metric timing is different being off by a rounding error. Would it make more sense to exclude this from the cherry pick?

In 9.6.0 so far :) There are a couple more changes coming down the line.

* source.
* Note that (presumably due to rounding to ms), the interaction duration may not
* be the same value as `maxDuration`, just the closest value. Function will throw
* if the closest match is off by more than 4ms.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: instead of throw, maybe return null? would force caller to be sure to handle it

or is there a reason you'd prefer this computed artifact to error when no interaction is present?

Copy link
Collaborator

Choose a reason for hiding this comment

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

compute_ already returns a nullable value, so might as well make this function do that too?

Copy link
Member Author

@brendankenny brendankenny May 9, 2022

Choose a reason for hiding this comment

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

This shouldn't be a thing that happens, even the 4ms difference needs to be fixed upstream (something weird is happening with rounding before the trace events are emitted), so I'm ok calling it a fatal case.

FWIW I've never hit a case of 5ms, so I don't think this should happen in practice except in actually exceptional cases (like maybe an interaction right as the trace is starting or stopping and so the events are partially missing)

});

if (candidates.length) {
if (!candidates[0].args.data.frame) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: unnest?

keyboard: KEYBOARD_EVENTS,
tapOrClick: CLICK_TAP_DRAG_EVENTS,
drag: CLICK_TAP_DRAG_EVENTS,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Map?

Copy link
Member Author

Choose a reason for hiding this comment

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

Map?

It's probably better but in practice doesn't make any difference since it's not dynamic and the declaration is a lot uglier :)

}
// TODO: seems to regularly happen up to 3ms and as high as 4.
if (minDurationDiff > 5) {
throw new Error(`no interaction event found within 5ms of responsiveness maxDuration (max: ${maxDuration}, closest ${bestMatchEvent.args.data.duration})`); // eslint-disable-line max-len
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is 5, but above in jsdoc "4ms" is mentioned as the threshold

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 is 5, but above in jsdoc "4ms" is mentioned as the threshold

yeah, it was to be really extra sure but I'll clarify, thx

@brendankenny
Copy link
Member Author

On reflection, these event.dur changes are too invasive. I'll revert and put the TODO on the AsyncEvent needing to have its dur removed.

"displayValue": "60 ms"
"score": null,
"scoreDisplayMode": "error",
"errorMessage": "This version of Chrome is too old to support 'detailed EventTiming trace events'. Use a newer version to see full results."
Copy link
Member

Choose a reason for hiding this comment

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

Could you rebaseline the flow artifacts? Should be able to use --rebaseline-artifacts Trace but there is no flag to modify a specific flow step yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you rebaseline the flow artifacts? Should be able to use --rebaseline-artifacts Trace but there is no flag to modify a specific flow step yet.

TypeError: Cannot set property startTime of #<PerformanceEntry> which has only a getter
    at Object.normalizeTimingEntries (~/lighthouse/lighthouse-core/lib/asset-saver.js:324:22)
    at rebaselineArtifacts (~/lighthouse/lighthouse-core/scripts/update-flow-fixtures.js:114:16)
    at async ~/lighthouse/lighthouse-core/scripts/update-flow-fixtures.js:157:7

I'll add it to the TODO list in #13916 and we can fix/update in a follow up.

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

4 participants