Skip to content

Commit d09625d

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Correctly map profile data to original sources
The original code was now using the resolved UILocation's line/col in the profile data, instead always using the raw location no matter if the resolved UISourceCode was mapped via source maps. Now the UILocation line/col is used. Additionally, we continue to provide profile data for the generated file, as it's expected users may switch between the two views of the same script when getting deep into performance issues. Bug: 462212096 Change-Id: I8e7ee303020f7ba28e78434c679229ec75872749 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7173541 Auto-Submit: Connor Clark <cjamcl@chromium.org> Commit-Queue: Connor Clark <cjamcl@chromium.org> Reviewed-by: Paul Irish <paulirish@chromium.org>
1 parent 0fdc7b9 commit d09625d

1 file changed

Lines changed: 32 additions & 11 deletions

File tree

front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,21 @@ export class Helper {
231231
String(scriptIdOrUrl) as Protocol.Runtime.ScriptId, zeroBasedLine, zeroBasedColumn || 0);
232232
if (rawLocation) {
233233
pending.push(workspaceBinding.rawLocationToUILocation(rawLocation).then(uiLocation => {
234-
if (uiLocation) {
235-
let lineMap = decorationsBySource.get(uiLocation.uiSourceCode);
236-
if (!lineMap) {
237-
lineMap = new Map();
238-
decorationsBySource.set(uiLocation.uiSourceCode, lineMap);
239-
}
240-
let columnMap = lineMap.get(lineNumber);
241-
if (!columnMap) {
242-
columnMap = new Map();
243-
lineMap.set(lineNumber, columnMap);
234+
if (!uiLocation) {
235+
return;
236+
}
237+
238+
this.addLineColumnData(
239+
decorationsBySource, uiLocation.uiSourceCode, uiLocation.lineNumber + 1,
240+
(uiLocation.columnNumber ?? 0) + 1, data);
241+
242+
// If the above was a source mapped UILocation, then we also need to add it to the generated UILocation.
243+
if (uiLocation.uiSourceCode.contentType().isFromSourceMap()) {
244+
const script = rawLocation.script();
245+
const uiSourceCode = script ? workspaceBinding.uiSourceCodeForScript(script) : null;
246+
if (uiSourceCode) {
247+
this.addLineColumnData(decorationsBySource, uiSourceCode, lineNumber, columnNumber, data);
244248
}
245-
columnMap.set((zeroBasedColumn || 0) + 1, data);
246249
}
247250
}));
248251
}
@@ -267,4 +270,22 @@ export class Helper {
267270
}
268271
}
269272
}
273+
274+
private addLineColumnData(
275+
decorationsBySource: ProfileDataMap, uiSourceCode: Workspace.UISourceCode.UISourceCode, lineOneIndexed: number,
276+
columnOneIndexed: number, data: number): void {
277+
let lineMap = decorationsBySource.get(uiSourceCode);
278+
if (!lineMap) {
279+
lineMap = new Map();
280+
decorationsBySource.set(uiSourceCode, lineMap);
281+
}
282+
283+
let columnMap = lineMap.get(lineOneIndexed);
284+
if (!columnMap) {
285+
columnMap = new Map();
286+
lineMap.set(lineOneIndexed, columnMap);
287+
}
288+
289+
columnMap.set(columnOneIndexed, (columnMap.get(columnOneIndexed) ?? 0) + data);
290+
}
270291
}

0 commit comments

Comments
 (0)