Skip to content

Commit 9ccbf7c

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Remove parsedTrace from insight components
Bug: 371615739 Change-Id: I34ee121183fc547ae0a15683a55423fd361bdfdf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6064209 Auto-Submit: Connor Clark <[email protected]> Reviewed-by: Adriana Ixba <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent abf30a1 commit 9ccbf7c

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

front_end/panels/timeline/components/SidebarInsightsTab.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ export class SidebarInsightsTab extends HTMLElement {
193193
<div class="insight-sets-wrapper">
194194
${[...this.#insights.values()].map(({id, url}, index) => {
195195
const data = {
196-
parsedTrace: this.#parsedTrace,
197196
insights: this.#insights,
198197
insightSetKey: id,
199198
activeCategory: this.#selectedCategory,

front_end/panels/timeline/components/SidebarSingleInsightSet.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function getPassedInsights(component: Components.SidebarSingleInsightSet.Sidebar
3232

3333
describeWithEnvironment('SidebarSingleInsightSet', () => {
3434
it('renders a list of insights', async function() {
35-
const {parsedTrace, insights} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
35+
const {insights} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
3636

3737
assert.isOk(insights);
3838
// only one navigation in this trace.
@@ -44,7 +44,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
4444
const component = new Components.SidebarSingleInsightSet.SidebarSingleInsightSet();
4545
renderElementIntoDOM(component);
4646
component.data = {
47-
parsedTrace,
4847
insights,
4948
insightSetKey: navigationId,
5049
activeCategory: Trace.Insights.Types.InsightCategory.ALL,
@@ -83,7 +82,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
8382
const firstNavigation = parsedTrace.Meta.mainFrameNavigations.at(0)?.args.data?.navigationId;
8483
assert.isOk(firstNavigation);
8584
component.data = {
86-
parsedTrace,
8785
insights,
8886
insightSetKey: firstNavigation,
8987
activeCategory: Trace.Insights.Types.InsightCategory.ALL,
@@ -97,7 +95,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
9795
assert.deepEqual(userVisibleTitles, [
9896
'LCP by phase',
9997
'LCP request discovery',
100-
'Layout shift culprits',
10198
'Improve image delivery',
10299
'Third parties',
103100
'Document request latency',
@@ -126,7 +123,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
126123
const firstNavigation = parsedTrace.Meta.mainFrameNavigations.at(0)?.args.data?.navigationId;
127124
assert.isOk(firstNavigation);
128125
component.data = {
129-
parsedTrace,
130126
insights,
131127
insightSetKey: firstNavigation,
132128
activeCategory: Trace.Insights.Types.InsightCategory.ALL,
@@ -140,7 +136,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
140136
assert.deepEqual(userVisibleTitles, [
141137
'LCP by phase',
142138
'LCP request discovery',
143-
'Layout shift culprits',
144139
'Improve image delivery',
145140
'Font display',
146141
'Third parties',
@@ -160,7 +155,7 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
160155
});
161156

162157
it('will render the active insight fully', async function() {
163-
const {parsedTrace, insights} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
158+
const {insights} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
164159

165160
assert.isOk(insights);
166161
// only one navigation in this trace.
@@ -177,7 +172,6 @@ describeWithEnvironment('SidebarSingleInsightSet', () => {
177172
const component = new Components.SidebarSingleInsightSet.SidebarSingleInsightSet();
178173
renderElementIntoDOM(component);
179174
component.data = {
180-
parsedTrace,
181175
insights,
182176
insightSetKey: navigationId,
183177
activeCategory: Trace.Insights.Types.InsightCategory.ALL,

front_end/panels/timeline/components/SidebarSingleInsightSet.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/SidebarSing
3434
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
3535

3636
export interface SidebarSingleInsightSetData {
37-
parsedTrace: Trace.Handlers.Types.ParsedTrace|null;
3837
insights: Trace.Insights.Types.TraceInsightSets|null;
3938
insightSetKey: Trace.Types.Events.NavigationId|null;
4039
activeCategory: Trace.Insights.Types.InsightCategory;
@@ -74,7 +73,6 @@ export class SidebarSingleInsightSet extends HTMLElement {
7473
#renderBound = this.#render.bind(this);
7574

7675
#data: SidebarSingleInsightSetData = {
77-
parsedTrace: null,
7876
insights: null,
7977
insightSetKey: null,
8078
activeCategory: Trace.Insights.Types.InsightCategory.ALL,
@@ -202,18 +200,18 @@ export class SidebarSingleInsightSet extends HTMLElement {
202200

203201
#renderInsights(
204202
insightSets: Trace.Insights.Types.TraceInsightSets|null,
205-
parsedTrace: Trace.Handlers.Types.ParsedTrace|null,
206203
insightSetKey: string,
207204
): LitHtml.LitTemplate {
208205
const includeExperimental = Root.Runtime.experiments.isEnabled(
209206
Root.Runtime.ExperimentName.TIMELINE_EXPERIMENTAL_INSIGHTS,
210207
);
211208

212-
const models = insightSets?.get(insightSetKey)?.model;
213-
if (!models) {
209+
const insightSet = insightSets?.get(insightSetKey);
210+
if (!insightSet) {
214211
return LitHtml.nothing;
215212
}
216213

214+
const models = insightSet.model;
217215
const shownInsights: LitHtml.TemplateResult[] = [];
218216
const passedInsights: LitHtml.TemplateResult[] = [];
219217
for (const [name, componentClass] of Object.entries(INSIGHT_NAME_TO_COMPONENT)) {
@@ -232,7 +230,7 @@ export class SidebarSingleInsightSet extends HTMLElement {
232230
<${componentClass.litTagName}
233231
.selected=${this.#data.activeInsight?.model === model}
234232
.model=${model}
235-
.parsedTrace=${parsedTrace}
233+
.bounds=${insightSet.bounds}
236234
.insightSetKey=${insightSetKey}
237235
</${componentClass.litTagName}>
238236
</div>`;
@@ -262,11 +260,10 @@ export class SidebarSingleInsightSet extends HTMLElement {
262260

263261
#render(): void {
264262
const {
265-
parsedTrace,
266263
insights,
267264
insightSetKey,
268265
} = this.#data;
269-
if (!parsedTrace || !insights || !insightSetKey) {
266+
if (!insights || !insightSetKey) {
270267
LitHtml.render(html``, this.#shadow, {host: this});
271268
return;
272269
}
@@ -275,7 +272,7 @@ export class SidebarSingleInsightSet extends HTMLElement {
275272
LitHtml.render(html`
276273
<div class="navigation">
277274
${this.#renderMetrics(insightSetKey)}
278-
${this.#renderInsights(insights, parsedTrace, insightSetKey)}
275+
${this.#renderInsights(insights, insightSetKey)}
279276
</div>
280277
`, this.#shadow, {host: this});
281278
// clang-format on

front_end/panels/timeline/components/insights/BaseInsightComponent.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/insights/Ba
4444
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
4545

4646
export interface BaseInsightData {
47-
parsedTrace: Trace.Handlers.Types.ParsedTrace|null;
47+
bounds: Trace.Types.Timing.TraceWindowMicroSeconds|null;
4848
/** The key into `insights` that contains this particular insight. */
4949
insightSetKey: string|null;
5050
}
@@ -65,7 +65,7 @@ export abstract class BaseInsightComponent<T extends InsightModel<{}>> extends H
6565
}
6666

6767
protected data: BaseInsightData = {
68-
parsedTrace: null,
68+
bounds: null,
6969
insightSetKey: null,
7070
};
7171

@@ -107,13 +107,13 @@ export abstract class BaseInsightComponent<T extends InsightModel<{}>> extends H
107107
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
108108
}
109109

110-
set parsedTrace(parsedTrace: Trace.Handlers.Types.ParsedTrace|null) {
111-
this.data.parsedTrace = parsedTrace;
110+
set insightSetKey(insightSetKey: string|null) {
111+
this.data.insightSetKey = insightSetKey;
112112
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
113113
}
114114

115-
set insightSetKey(insightSetKey: string|null) {
116-
this.data.insightSetKey = insightSetKey;
115+
set bounds(bounds: Trace.Types.Timing.TraceWindowMicroSeconds|null) {
116+
this.data.bounds = bounds;
117117
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
118118
}
119119

front_end/panels/timeline/components/insights/CLSCulprits.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ export class CLSCulprits extends BaseInsightComponent<CLSCulpritsInsightModel> {
127127

128128
#renderContent(culprits: Array<string>, worstCluster: Trace.Types.Events.SyntheticLayoutShiftCluster):
129129
LitHtml.LitTemplate {
130-
const ts = Trace.Types.Timing.MicroSeconds(worstCluster.ts - (this.data.parsedTrace?.Meta.traceBounds.min ?? 0));
130+
if (!this.bounds) {
131+
return LitHtml.nothing;
132+
}
133+
134+
const ts = Trace.Types.Timing.MicroSeconds(worstCluster.ts - this.bounds.min);
131135
const clusterTs = i18n.TimeUtilities.formatMicroSecondsTime(ts);
132136

133137
// clang-format off

0 commit comments

Comments
 (0)