-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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(metrics): support FCP for all frames with devtools throttling #11874
Changes from all commits
ae8eb00
da642b4
402b448
d979246
7de15b7
127276b
8fe525b
fbd963f
9360bb7
cb73c58
e91c3f0
c626fe5
ab163b2
2d931df
562c4f3
200ce02
6ab0900
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<div id="space"></div> | ||
<h1>THIS IS THE INNER FRAME LCP AND FCP</h1> | ||
<script> | ||
const space = document.getElementById('space'); | ||
setTimeout(() => { | ||
space.style.height = 200; | ||
}, 200); | ||
setTimeout(() => { | ||
space.style.height = 400; | ||
}, 400); | ||
setTimeout(() => { | ||
space.style.height = 600; | ||
}, 600); | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<iframe id="frame" src="frame-metrics-inner.html" width="100%" height="700"></iframe> | ||
<div id="space"></div> | ||
<div> | ||
<span id="content"></span> | ||
</div> | ||
<script> | ||
const space = document.getElementById('space'); | ||
const content = document.getElementById('content'); | ||
|
||
const keepAliveInterval = setInterval(() => { | ||
const start = new Date(); | ||
let now = start; | ||
while (now - start < 51) { | ||
now = new Date(); | ||
} | ||
}, 1000); | ||
setTimeout(() => clearInterval(keepAliveInterval), 8000); | ||
|
||
// The innerHTML will be the LCP and FCP of the main frame. | ||
// It is painted after the inner frame FCP, and it is smaller than the inner frame LCP. | ||
// The metrics for all frames will therefore be different than the metrics for the main frame. | ||
setTimeout(() => { | ||
content.innerHTML = 'This is the main frame LCP and FCP.'; | ||
|
||
// Add a small layout shift in the main frame. | ||
// More layout shifts occur in the inner frame. | ||
// CLS for all frames will therefore, be different than CLS for main frame. | ||
setTimeout(() => { | ||
space.style.height = '100'; | ||
}, 50); | ||
}, 5000); | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
const makeComputedArtifact = require('../computed-artifact.js'); | ||
const ComputedMetric = require('./metric.js'); | ||
|
||
class FirstContentfulPaintAllFrames extends ComputedMetric { | ||
/** | ||
* @return {Promise<LH.Artifacts.LanternMetric>} | ||
*/ | ||
static computeSimulatedMetric() { | ||
// TODO: Add support for all frames in lantern. | ||
throw new Error('FCP All Frames not implemented in lantern'); | ||
} | ||
|
||
/** | ||
* @param {LH.Artifacts.MetricComputationData} data | ||
* @return {Promise<LH.Artifacts.Metric>} | ||
*/ | ||
static async computeObservedMetric(data) { | ||
const {traceOfTab} = data; | ||
|
||
return { | ||
timing: traceOfTab.timings.firstContentfulPaintAllFrames, | ||
timestamp: traceOfTab.timestamps.firstContentfulPaintAllFrames, | ||
}; | ||
} | ||
} | ||
|
||
module.exports = makeComputedArtifact(FirstContentfulPaintAllFrames); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ Object { | |
"firstCPUIdle": 863, | ||
"firstCPUIdleTs": 23466886143, | ||
"firstContentfulPaint": 863, | ||
"firstContentfulPaintAllFrames": 683, | ||
"firstContentfulPaintAllFramesTs": 23466705983, | ||
"firstContentfulPaintTs": 23466886143, | ||
"firstMeaningfulPaint": 863, | ||
"firstMeaningfulPaintTs": 23466886143, | ||
|
@@ -24,6 +26,8 @@ Object { | |
"observedDomContentLoaded": 596, | ||
"observedDomContentLoadedTs": 23466619325, | ||
"observedFirstContentfulPaint": 863, | ||
"observedFirstContentfulPaintAllFrames": 683, | ||
"observedFirstContentfulPaintAllFramesTs": 23466705983, | ||
"observedFirstContentfulPaintTs": 23466886143, | ||
"observedFirstMeaningfulPaint": 863, | ||
"observedFirstMeaningfulPaintTs": 23466886143, | ||
|
@@ -62,6 +66,8 @@ Object { | |
"firstCPUIdle": 3790, | ||
"firstCPUIdleTs": undefined, | ||
"firstContentfulPaint": 2289, | ||
"firstContentfulPaintAllFrames": undefined, | ||
"firstContentfulPaintAllFramesTs": undefined, | ||
"firstContentfulPaintTs": undefined, | ||
"firstMeaningfulPaint": 2758, | ||
"firstMeaningfulPaintTs": undefined, | ||
|
@@ -77,6 +83,8 @@ Object { | |
"observedDomContentLoaded": 1513, | ||
"observedDomContentLoadedTs": 713038536140, | ||
"observedFirstContentfulPaint": 1122, | ||
"observedFirstContentfulPaintAllFrames": 1122, | ||
"observedFirstContentfulPaintAllFramesTs": 713038144775, | ||
"observedFirstContentfulPaintTs": 713038144775, | ||
"observedFirstMeaningfulPaint": 1122, | ||
"observedFirstMeaningfulPaintTs": 713038144775, | ||
|
@@ -85,8 +93,8 @@ Object { | |
"observedFirstVisualChange": 1105, | ||
"observedFirstVisualChangeTs": 713038128064, | ||
"observedLargestContentfulPaint": 1122, | ||
"observedLargestContentfulPaintAllFrames": undefined, | ||
"observedLargestContentfulPaintAllFramesTs": undefined, | ||
"observedLargestContentfulPaintAllFrames": 1122, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, why did this one change? I wouldn't have expected movement here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, if there were no Now that |
||
"observedLargestContentfulPaintAllFramesTs": 713038144775, | ||
"observedLargestContentfulPaintTs": 713038144775, | ||
"observedLastVisualChange": 1722, | ||
"observedLastVisualChangeTs": 713038745064, | ||
|
@@ -115,6 +123,8 @@ Object { | |
"firstCPUIdle": 1582, | ||
"firstCPUIdleTs": 225415754204, | ||
"firstContentfulPaint": 499, | ||
"firstContentfulPaintAllFrames": 499, | ||
"firstContentfulPaintAllFramesTs": 225414670885, | ||
"firstContentfulPaintTs": 225414670885, | ||
"firstMeaningfulPaint": 783, | ||
"firstMeaningfulPaintTs": 225414955343, | ||
|
@@ -130,6 +140,8 @@ Object { | |
"observedDomContentLoaded": 560, | ||
"observedDomContentLoadedTs": 225414732309, | ||
"observedFirstContentfulPaint": 499, | ||
"observedFirstContentfulPaintAllFrames": 499, | ||
"observedFirstContentfulPaintAllFramesTs": 225414670885, | ||
"observedFirstContentfulPaintTs": 225414670885, | ||
"observedFirstMeaningfulPaint": 783, | ||
"observedFirstMeaningfulPaintTs": 225414955343, | ||
|
@@ -168,6 +180,8 @@ Object { | |
"firstCPUIdle": 4313, | ||
"firstCPUIdleTs": undefined, | ||
"firstContentfulPaint": 1337, | ||
"firstContentfulPaintAllFrames": undefined, | ||
"firstContentfulPaintAllFramesTs": undefined, | ||
"firstContentfulPaintTs": undefined, | ||
"firstMeaningfulPaint": 1553, | ||
"firstMeaningfulPaintTs": undefined, | ||
|
@@ -183,6 +197,8 @@ Object { | |
"observedDomContentLoaded": 560, | ||
"observedDomContentLoadedTs": 225414732309, | ||
"observedFirstContentfulPaint": 499, | ||
"observedFirstContentfulPaintAllFrames": 499, | ||
"observedFirstContentfulPaintAllFramesTs": 225414670885, | ||
"observedFirstContentfulPaintTs": 225414670885, | ||
"observedFirstMeaningfulPaint": 783, | ||
"observedFirstMeaningfulPaintTs": 225414955343, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautiful 👍