Skip to content

Conversation

@LukasAuerMstage
Copy link
Contributor

Summary
This PR adds an additional check for whether the node startTime is beyond the paint timestamp, optional to the existing check for the endTime, to exclude nodes that have a startTime beyond the timestamp but a negative endTime.

The fix is required because otherwise certain nodes, such as prefetch resource hints, might be incorrectly added to the lcp graph.

Related Issues/PRs
#11856

…rder to catch network nodes that have a negative end time
@google-cla
Copy link

google-cla bot commented Dec 22, 2020

☹️ Sorry, but only Googlers may change the label cla: yes.

@google-cla google-cla bot added the cla: yes label Dec 22, 2020
@LukasAuerMstage
Copy link
Contributor Author

I have a hard time reproducing these pretty significant differences between expected and actual LCP values that get reported by the failed tests as my local results are much more subtle and similar. Nevertheless, some improvements in the LCP values are to be expected i suppose.

Copy link
Contributor

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Could you add a unit test for this as well?

Co-authored-by: Adam Raine <[email protected]>
Copy link
Contributor

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Nice work on the test cases, look good overall.

* @license Copyright 2020 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.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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


describe('Exclude unfinished resources from graph', () => {
it('shouldn\'t be included in the graph if start time is past the paint timestamp', async () => {
const networkRecords = [
Copy link
Contributor

Choose a reason for hiding this comment

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

You can create a test trace and devtools log using these functions:

const createTestTrace = require('../../create-test-trace.js');
const networkRecordsToDevtoolsLog = require('../../network-records-to-devtools-log.js');

Keep in mind that createTestTrace adds an FCP event automatically.

Check out https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/test/audits/third-party-facades-test.js for a usage example.

const {
optimisticGraph,
pessimisticGraph,
} = getComputedGraphs(
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of creating getComputedGraphs as a test function, request the metric directly:

const result = await LanternFirstContentfulPaint.request({trace, devtoolsLog, settings}, context)`

Get the graphs from result.optimisticGraph and result.pessimisticGraph.

Check out https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/test/computed/metrics/lantern-first-contentful-paint-test.js for usage reference.

const NetworkRequest = require('../../lib/network-request.js');
const BaseNode = require('../../lib/dependency-graph/base-node.js');
const PageDependencyGraph = require('../../computed/page-dependency-graph.js');
const LanternLCP = require('../../computed/metrics/lantern-largest-contentful-paint.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

This change affects the lantern FCP graph directly, it makes more sense to use that:

const LanternFirstContentfulPaint = require('../../../computed/metrics/lantern-first-contentful-paint.js');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants