Skip to content

Commit

Permalink
Ensure we flush performance ticks when the PerformanceObserver fires. (
Browse files Browse the repository at this point in the history
…#11375)

While this will not make a difference for the vast majority of cases, it is not defined when PerformanceObserver fires and it might have been after all other flushes.
  • Loading branch information
cramforce authored and camelburrito committed Sep 25, 2017
1 parent df3ff42 commit 3287c42
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ export class Performance {
}

// Tick window.onload event.
whenDocumentComplete(win.document).then(() => {
this.onload_();
this.flush();
});

whenDocumentComplete(win.document).then(() => this.onload_());
this.registerPaintTimingObserver_();
}

Expand Down Expand Up @@ -165,6 +161,7 @@ export class Performance {
onload_() {
this.tick('ol');
this.tickLegacyFirstPaintTime_();
this.flush();
}

/**
Expand All @@ -179,9 +176,11 @@ export class Performance {
list.getEntries().forEach(entry => {
if (entry.name == 'first-paint') {
this.tickDelta('fp', entry.startTime + entry.duration);
this.flush();
}
else if (entry.name == 'first-contentful-paint') {
this.tickDelta('fcp', entry.startTime + entry.duration);
this.flush();
}
});
});
Expand Down

0 comments on commit 3287c42

Please sign in to comment.