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

deps: upgrade trace_engine to 0.0.38 #16269

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cli/test/smokehouse/test-definitions/dobetterweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,22 @@ const expectations = {
details: {
items: [
{
url: 'http://localhost:10200/dobetterweb/dbw_tester.css?delay=100',
url: 'http://localhost:10200/dobetterweb/fcp-delayer.js?delay=5000',
},
{
url: 'http://localhost:10200/dobetterweb/unknown404.css?delay=200',
url: 'http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped',
},
{
url: 'http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200',
},
{
url: 'http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped',
url: 'http://localhost:10200/dobetterweb/dbw_tester.js',
},
{
url: 'http://localhost:10200/dobetterweb/dbw_tester.js',
url: 'http://localhost:10200/dobetterweb/unknown404.css?delay=200',
},
{
url: 'http://localhost:10200/dobetterweb/fcp-delayer.js?delay=5000',
url: 'http://localhost:10200/dobetterweb/dbw_tester.css?delay=100',
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why the order changes here? Looks like the order comes directly from TE so maybe some updated a while back applied a sort.

Copy link
Collaborator Author

@connorjclark connorjclark Dec 2, 2024

Choose a reason for hiding this comment

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

it's sorted:

"// Sort by request duration for insights."

https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5867686

},
],
},
Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/render-blocking-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class RenderBlockingResources extends Audit {
const wastedCssBytes = await RenderBlockingResources.computeWastedCSSBytes(artifacts, context);
const navInsights = await NavigationInsights.request(trace, context);

const renderBlocking = navInsights.RenderBlocking;
const renderBlocking = navInsights.model.RenderBlocking;
if (renderBlocking instanceof Error) throw renderBlocking;

/** @type {LH.Audit.Context['settings']} */
Expand Down
8 changes: 4 additions & 4 deletions core/computed/metrics/cumulative-layout-shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ class CumulativeLayoutShift {
Screenshots: TraceEngine.TraceHandlers.Screenshots,
});
// eslint-disable-next-line max-len
await processor.parse(/** @type {import('@paulirish/trace_engine').Types.TraceEvents.TraceEventData[]} */ (
await processor.parse(/** @type {import('@paulirish/trace_engine').Types.Events.Event[]} */ (
events
));
if (!processor.traceParsedData) {
), {});
if (!processor.parsedTrace) {
throw new Error('null trace engine result');
}
return processor.traceParsedData.LayoutShifts.sessionMaxScore;
return processor.parsedTrace.LayoutShifts.sessionMaxScore;
};
const cumulativeLayoutShift = await run(allFrameShiftEvents.map(e => e.event));
const cumulativeLayoutShiftMainFrame = await run(mainFrameShiftEvents.map(e => e.event));
Expand Down
6 changes: 4 additions & 2 deletions core/computed/metrics/lantern-metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ async function getComputationDataParamsFromTrace(data, context) {

const graph = await PageDependencyGraph.request({...data, fromTrace: true}, context);
const traceEngineResult = await TraceEngineResult.request(data, context);
const processedNavigation =
Lantern.TraceEngineComputationData.createProcessedNavigation(traceEngineResult.data);
const frameId = traceEngineResult.data.Meta.mainFrameId;
const navigationId = traceEngineResult.data.Meta.mainFrameNavigations[0].args.data.navigationId;
const processedNavigation = Lantern.TraceEngineComputationData.createProcessedNavigation(
traceEngineResult.data, frameId, navigationId);
const simulator = data.simulator || (await LoadSimulator.request(data, context));

return {simulator, graph, processedNavigation};
Expand Down
6 changes: 5 additions & 1 deletion core/computed/network-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class NetworkAnalysis {
*/
static async compute_(devtoolsLog, context) {
const records = await NetworkRecords.request(devtoolsLog, context);
return Lantern.Core.NetworkAnalyzer.analyze(records);
const analyis = Lantern.Core.NetworkAnalyzer.analyze(records);
if (!analyis) {
throw new Error('Could not compute network analysis');
}
return analyis;
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/computed/trace-engine-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class TraceEngineResult {
const processor = new TraceEngine.TraceProcessor(traceHandlers);

// eslint-disable-next-line max-len
await processor.parse(/** @type {import('@paulirish/trace_engine').Types.TraceEvents.TraceEventData[]} */ (
await processor.parse(/** @type {import('@paulirish/trace_engine').Types.Events.Event[]} */ (
traceEvents
));
if (!processor.traceParsedData) throw new Error('No data');
), {});
if (!processor.parsedTrace) throw new Error('No data');
if (!processor.insights) throw new Error('No insights');
return {data: processor.traceParsedData, insights: processor.insights};
return {data: processor.parsedTrace, insights: processor.insights};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/lib/trace-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as TraceEngine from '@paulirish/trace_engine';

import {polyfillDOMRect} from './polyfill-dom-rect.js';

/** @typedef {import('@paulirish/trace_engine').Types.TraceEvents.SyntheticLayoutShift} SyntheticLayoutShift */
/** @typedef {import('@paulirish/trace_engine').Types.Events.SyntheticLayoutShift} SyntheticLayoutShift */
/** @typedef {SyntheticLayoutShift & {args: {data: NonNullable<SyntheticLayoutShift['args']['data']>}}} SaneSyntheticLayoutShift */

polyfillDOMRect();
Expand Down
2 changes: 1 addition & 1 deletion core/test/audits/dobetterweb/dom-size-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('DOMSize audit', () => {

beforeEach(() => {
const mainDocumentUrl = 'https://example.com/';
const networkRecords = [{url: mainDocumentUrl, priority: 'High'}];
const networkRecords = [{url: mainDocumentUrl, priority: 'High', transferSize: 1000}];
const trace = createTestTrace({
largestContentfulPaint: 15,
topLevelTasks: [
Expand Down
13 changes: 13 additions & 0 deletions core/test/audits/dobetterweb/uses-http2-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,37 @@ describe('Resources are fetched over http/2', () => {
it('should pass when resources are requested via http/2', async () => {
const networkRecords = [{
url: 'https://www.example.com/',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
{
url: 'https://www.example.com/2',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
{
url: 'https://www.example.com/3',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
{
url: 'https://www.example.com/4',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
{
url: 'https://www.example.com/5',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
{
url: 'https://www.example.com/6',
transferSize: 1000,
priority: 'High',
protocol: 'h2',
},
Expand Down Expand Up @@ -267,36 +273,43 @@ describe('Resources are fetched over http/2', () => {
const networkRecords = [
{
url: 'https://www.twitter.com/',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.twitter.com/2',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.twitter.com/3',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.twitter.com/4',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.twitter.com/5',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.twitter.com/embed/foo',
transferSize: 1000,
priority: 'High',
protocol: 'HTTP/1.1',
},
{
url: 'https://www.facebook.com/embed',
transferSize: 1000,
protocol: 'HTTP/1.1',
priority: 'High',
},
Expand Down
1 change: 1 addition & 0 deletions core/test/audits/long-tasks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('Long tasks audit', () => {
url: TASK_URL,
priority: 'High',
timing: {connectEnd: 50, connectStart: 0.01, sslStart: 25, sslEnd: 40},
transferSize: 1000,
}];

const artifacts = {
Expand Down
9 changes: 9 additions & 0 deletions core/test/audits/redirects-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const FAILING_THREE_REDIRECTS = [{
priority: 'VeryHigh',
url: 'https://m.example.com/final',
timing: {receiveHeadersEnd: 19},
transferSize: 1000,
}];

const FAILING_TWO_REDIRECTS = [{
Expand All @@ -54,6 +55,7 @@ const FAILING_TWO_REDIRECTS = [{
priority: 'VeryHigh',
url: 'https://www.lisairish.com/',
timing: {receiveHeadersEnd: 448},
transferSize: 1000,
}];

const SUCCESS_ONE_REDIRECT = [{
Expand All @@ -68,6 +70,7 @@ const SUCCESS_ONE_REDIRECT = [{
priority: 'VeryHigh',
url: 'https://www.lisairish.com/',
timing: {receiveHeadersEnd: 139},
transferSize: 1000,
}];

const SUCCESS_NOREDIRECT = [{
Expand All @@ -76,6 +79,7 @@ const SUCCESS_NOREDIRECT = [{
priority: 'VeryHigh',
url: 'https://www.google.com/',
timing: {receiveHeadersEnd: 140},
transferSize: 1000,
}];

const FAILING_CLIENTSIDE = [
Expand All @@ -92,13 +96,15 @@ const FAILING_CLIENTSIDE = [
priority: 'VeryHigh',
url: 'https://lisairish.com/',
timing: {receiveHeadersEnd: 447},
transferSize: 1000,
},
{
requestId: '2',
networkRequestTime: 447_000,
priority: 'VeryHigh',
url: 'https://www.lisairish.com/',
timing: {receiveHeadersEnd: 448},
transferSize: 1000,
},
];

Expand All @@ -108,20 +114,23 @@ const FAILING_SELF_REDIRECT = [{
priority: 'VeryHigh',
networkRequestTime: 0,
responseHeadersEndTime: 500,
transferSize: 1000,
},
{
requestId: '2',
url: 'https://redirect.test/',
priority: 'VeryHigh',
networkRequestTime: 1000,
responseHeadersEndTime: 1500,
transferSize: 1000,
},
{
requestId: '3',
url: 'https://redirect.test/',
priority: 'VeryHigh',
networkRequestTime: 3000,
responseHeadersEndTime: 3500,
transferSize: 1000,
}];

describe('Performance: Redirects audit', () => {
Expand Down
4 changes: 4 additions & 0 deletions core/test/audits/uses-rel-preconnect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const mainResource = {
};

function buildArtifacts(networkRecords, fcpTs) {
for (const record of networkRecords) {
record.transferSize = record.transferSize ?? 1000;
}

const trace = createTestTrace({
timeOrigin: 0,
largestContentfulPaint: 5000,
Expand Down
9 changes: 8 additions & 1 deletion core/test/audits/uses-rel-preload-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Performance: uses-rel-preload audit', () => {
{
requestId: '2',
networkRequestTime: 10_000,
transferSize: 1000,
isLinkPreload: false,
url: secondRecordUrl,
timing: defaultMainResource.timing,
Expand All @@ -63,6 +64,7 @@ describe('Performance: uses-rel-preload audit', () => {
// Normally this request would be flagged for preloading.
requestId: '3',
networkRequestTime: 20_000,
transferSize: 1000,
isLinkPreload: false,
url: 'http://www.example.com/a-different-script.js',
timing: defaultMainResource.timing,
Expand Down Expand Up @@ -100,6 +102,7 @@ describe('Performance: uses-rel-preload audit', () => {
isLinkPreload: false,
networkRequestTime: 500,
networkEndTime: 1000,
transferSize: 1000,
timing: {receiveHeadersEnd: 500},
url: mainDocumentNodeUrl,
},
Expand All @@ -110,6 +113,7 @@ describe('Performance: uses-rel-preload audit', () => {
isLinkPreload: false,
networkRequestTime: 1000,
networkEndTime: 2000,
transferSize: 1000,
timing: {receiveHeadersEnd: 1000},
url: scriptNodeUrl,
initiator: {type: 'parser', url: mainDocumentNodeUrl},
Expand All @@ -121,6 +125,7 @@ describe('Performance: uses-rel-preload audit', () => {
isLinkPreload: false,
networkRequestTime: 2000,
networkEndTime: 3_250,
transferSize: 1000,
timing: {receiveHeadersEnd: 1250},
url: scriptAddedNodeUrl,
initiator: {type: 'script', url: scriptNodeUrl},
Expand All @@ -132,6 +137,7 @@ describe('Performance: uses-rel-preload audit', () => {
isLinkPreload: false,
networkRequestTime: 2000,
networkEndTime: 3000,
transferSize: 1000,
timing: {receiveHeadersEnd: 1000},
url: scriptSubNodeUrl,
initiator: {type: 'script', url: scriptNodeUrl},
Expand All @@ -143,6 +149,7 @@ describe('Performance: uses-rel-preload audit', () => {
isLinkPreload: false,
networkRequestTime: 2000,
networkEndTime: 3_500,
transferSize: 1000,
timing: {receiveHeadersEnd: 1500},
url: scriptOtherNodeUrl,
initiator: {type: 'script', url: scriptNodeUrl},
Expand Down Expand Up @@ -170,7 +177,7 @@ describe('Performance: uses-rel-preload audit', () => {
const artifacts = mockArtifacts(networkRecords, defaultMainResourceUrl);
const context = {settings: {}, computedCache: new Map()};
return UsesRelPreload.audit(artifacts, context).then(output => {
assert.equal(output.details.overallSavingsMs, 314);
assert.equal(output.details.overallSavingsMs, 303);
assert.equal(output.details.items.length, 1);
});
});
Expand Down
Loading
Loading