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(tsc): tighten traceOfTab timing types #5887

Merged
merged 4 commits into from
Aug 22, 2018
Merged

core(tsc): tighten traceOfTab timing types #5887

merged 4 commits into from
Aug 22, 2018

Conversation

brendankenny
Copy link
Member

#5873 needed fixes to traceOfTab's timings and timestamps creation, which is a good opportunity to take care of long-standing TODOs to fix the types for those objects. Basically most of their properties may not have been found in the trace but we were pretending they were all there to make dealing with them simpler.

We now throw on NO_FCP in so many places that maybe we should just call it required in a trace and throw in traceOfTab like we do for no navigationStart?

@@ -91,6 +92,9 @@ class RenderBlockingResources extends Audit {
const metricComputationData = {trace, devtoolsLog, simulator, settings: metricSettings};
// @ts-ignore - TODO(bckenny): allow optional `throttling` settings
const fcpSimulation = await artifacts.requestFirstContentfulPaint(metricComputationData);
if (!traceOfTab.timestamps.firstContentfulPaint) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@patrickhulce this one I was least sure about because it could have been an extra guard vs needed for correct behavior.

This arguably "works" if fcpTsInMs ends up as NaN as no resources will be ignored. I could change it to make that explicit instead of throwing instead.

@@ -90,6 +90,9 @@ class Interactive extends MetricArtifact {
* @return {{cpuQuietPeriod: TimePeriod, networkQuietPeriod: TimePeriod, cpuQuietPeriods: Array<TimePeriod>, networkQuietPeriods: Array<TimePeriod>}}
*/
static findOverlappingQuietPeriods(longTasks, networkRecords, traceOfTab) {
if (!traceOfTab.timestamps.firstContentfulPaint) {
throw new LHError(LHError.errors.NO_FCP);
}
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 was already checked down in computeObservedMetric(), but this seemed better than passing in the known-defined value as another parameter?

traceEnd: (timestamps.traceEnd - navigationStart.ts) / 1000,
load: getTiming(timestamps.load),
domContentLoaded: getTiming(timestamps.domContentLoaded),
};
Copy link
Member Author

Choose a reason for hiding this comment

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

happy to code golf on timestamps/timings creation :)

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.

I'm all for making FCP a required property at this point. Sprinkling NO_FCP everywhere seems worse than just updating the tests that need a fake FCP event

@brendankenny
Copy link
Member Author

Sprinkling NO_FCP everywhere seems worse than just updating the tests that need a fake FCP event

SG and @paulirish seemed 👍

Updated.

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 thanks for updating all those!

not super fun stuff I know :)

/** The trace event marking firstPaint, if it was found. */
firstPaintEvt?: TraceEvent;
/** The trace event marking firstContentfulPaint, if it was found. */
firstContentfulPaintEvt?: TraceEvent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one can be no ? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, good catch

@brendankenny brendankenny merged commit 4a2c085 into master Aug 22, 2018
@brendankenny brendankenny deleted the traceoftab branch August 22, 2018 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants