Skip to content

Commit abbbafd

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
Add Lantern settings to trace engine options
Lighthouse needs this. Bug: 388723721 Change-Id: I76d3ce7eff44274ce72b8c38733add8d6f0ae518 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6345303 Commit-Queue: Adam Raine <[email protected]> Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Connor Clark <[email protected]> Reviewed-by: Adam Raine <[email protected]>
1 parent c6a1873 commit abbbafd

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

front_end/models/trace/Processor.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class TraceProcessor extends EventTarget {
287287

288288
#createLanternContext(
289289
parsedTrace: Handlers.Types.ParsedTrace, traceEvents: readonly Types.Events.Event[], frameId: string,
290-
navigationId: string): Insights.Types.LanternContext|undefined {
290+
navigationId: string, options: Types.Configuration.ParseOptions): Insights.Types.LanternContext|undefined {
291291
// Check for required handlers.
292292
if (!parsedTrace.NetworkRequests || !parsedTrace.Workers || !parsedTrace.PageLoadMetrics) {
293293
return;
@@ -321,13 +321,15 @@ export class TraceProcessor extends EventTarget {
321321
return;
322322
}
323323

324+
const lanternSettings: Lantern.Types.Simulation.Settings = {
325+
// TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture
326+
// that? Do we need to set 'devtools' throttlingMethod?
327+
networkAnalysis,
328+
throttlingMethod: 'provided',
329+
...options.lanternSettings,
330+
};
324331
const simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest> =
325-
Lantern.Simulation.Simulator.createSimulator({
326-
// TODO(crbug.com/372674229): if devtools throttling was on, does this network analysis capture
327-
// that? Do we need to set 'devtools' throttlingMethod?
328-
networkAnalysis,
329-
throttlingMethod: 'provided',
330-
});
332+
Lantern.Simulation.Simulator.createSimulator(lanternSettings);
331333

332334
const computeData = {graph, simulator, processedNavigation};
333335
const fcpResult = Lantern.Metrics.FirstContentfulPaint.compute(computeData);
@@ -541,7 +543,7 @@ export class TraceProcessor extends EventTarget {
541543
let lantern;
542544
try {
543545
options.logger?.start('insights:createLanternContext');
544-
lantern = this.#createLanternContext(parsedTrace, traceEvents, frameId, navigationId);
546+
lantern = this.#createLanternContext(parsedTrace, traceEvents, frameId, navigationId, options);
545547
} catch (e) {
546548
// Don't allow an error in constructing the Lantern graphs to break the rest of the trace processor.
547549
// Log unexpected errors, but suppress anything that occurs from a trace being too old.

front_end/models/trace/lantern/types/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import("../../../visibility.gni")
1010
devtools_module("types") {
1111
sources = [ "Lantern.ts" ]
1212

13-
deps = [ "../../types:bundle" ]
13+
deps = [ "../../../../generated" ]
1414
}
1515

1616
devtools_entrypoint("bundle") {

front_end/models/trace/types/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ devtools_module("types") {
2020
"../../../core/sdk:bundle",
2121
"../../../generated",
2222
"../../crux-manager:bundle",
23+
"../lantern:bundle",
2324
]
2425
}
2526

front_end/models/trace/types/Configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type * as Platform from '../../../core/platform/platform.js';
66
import type * as SDK from '../../../core/sdk/sdk.js';
77
import type * as Protocol from '../../../generated/protocol.js';
8+
import type * as Lantern from '../lantern/lantern.js';
89

910
import type * as File from './File.js';
1011

@@ -73,6 +74,7 @@ export interface ParseOptions {
7374
start: (id: string) => void,
7475
end: (id: string) => void,
7576
};
77+
lanternSettings?: Omit<Lantern.Types.Simulation.Settings, 'networkAnalysis'>;
7678
}
7779

7880
export interface ResolveSourceMapParams {

0 commit comments

Comments
 (0)