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

Filter bad first-paint values. #9532

Merged
merged 2 commits into from May 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/service/performance-impl.js
Expand Up @@ -164,16 +164,7 @@ export class Performance {

onload_() {
this.tick('ol');
// Detect deprecated first pain time API
// https://bugs.chromium.org/p/chromium/issues/detail?id=621512
// We'll use this until something better is available.
if (!this.win.PerformancePaintTiming
&& this.win.chrome
&& typeof this.win.chrome.loadTimes == 'function') {
this.tickDelta('fp',
this.win.chrome.loadTimes().firstPaintTime * 1000 -
this.win.performance.timing.navigationStart);
}
this.tickLegacyFirstPaintTime_();
}

/**
Expand All @@ -198,6 +189,30 @@ export class Performance {
observer.observe({entryTypes: ['paint']});
}

/**
* Tick fp time based on Chrome's legacy paint timing API when
* appropriate.
* `registerPaintTimingObserver_` calls the standards based API and this
* method does nothing if it is available.
*/
tickLegacyFirstPaintTime_() {
// Detect deprecated first pain time API
// https://bugs.chromium.org/p/chromium/issues/detail?id=621512
// We'll use this until something better is available.
if (!this.win.PerformancePaintTiming
&& this.win.chrome
&& typeof this.win.chrome.loadTimes == 'function') {
const fpTime = this.win.chrome.loadTimes().firstPaintTime
* 1000 - this.win.performance.timing.navigationStart;
if (fpTime <= 1) {
// Throw away bad data generated from an apparent Chrome bug
// that is fixed in later Chrome versions.
return;
}
this.tickDelta('fp', fpTime);
}
}

/**
* Measure the delay the user perceives of how long it takes
* to load the initial viewport.
Expand Down