File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,9 @@ export const onFCP = (onReport: FCPReportCallback, opts?: ReportOpts) => {
5050 if ( entry . startTime < visibilityWatcher . firstHiddenTime ) {
5151 // The activationStart reference is used because FCP should be
5252 // relative to page activation rather than navigation start if the
53- // page was prerendered.
54- metric . value = entry . startTime - getActivationStart ( ) ;
53+ // page was prerendered. But in cases where `activationStart` occurs
54+ // after the FCP, this time should be clamped at 0.
55+ metric . value = Math . max ( entry . startTime - getActivationStart ( ) , 0 ) ;
5556 metric . entries . push ( entry ) ;
5657 report ( true ) ;
5758 }
Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ export const onLCP = (onReport: ReportCallback, opts?: ReportOpts) => {
5454 // The startTime attribute returns the value of the renderTime if it is
5555 // not 0, and the value of the loadTime otherwise. The activationStart
5656 // reference is used because LCP should be relative to page activation
57- // rather than navigation start if the page was prerendered.
58- const value = lastEntry . startTime - getActivationStart ( ) ;
57+ // rather than navigation start if the page was prerendered. But in cases
58+ // where `activationStart` occurs after the LCP, this time should be
59+ // clamped at 0.
60+ const value = Math . max ( lastEntry . startTime - getActivationStart ( ) , 0 ) ;
5961
6062 // Only report if the page wasn't hidden prior to LCP.
6163 if ( value < visibilityWatcher . firstHiddenTime ) {
You can’t perform that action at this time.
0 commit comments