Skip to content

Commit 792ed74

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: sort process windows before setting them
In the screenshot of the bug below, notice how for one process for a frame we end up setting its time range to invalid, negative numbers. This is because we were not sorting the windows first, which is required. We had an assumption that the timestamps of the trace events come in time order, but that is clearly not always true, so this CL updates the code to sort first to ensure we have them ordered correctly before we then set the bounds for each process. Bug: 402658800 Change-Id: I1b0a394f98cf4538f81cfa4debada97987655593 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6346911 Auto-Submit: Jack Franklin <[email protected]> Reviewed-by: Nancy Li <[email protected]> Commit-Queue: Nancy Li <[email protected]>
1 parent a28d2ab commit 792ed74

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

front_end/models/trace/handlers/MetaHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,13 @@ export async function finalize(): Promise<void> {
333333
// each particular renderer started and stopped being the main renderer
334334
// process.
335335
for (const [, processWindows] of rendererProcessesByFrameId) {
336-
const processWindowValues = [...processWindows.values()].flat();
336+
// Sort the windows by time; we cannot assume by default they arrive via
337+
// events in time order. Because we set the window bounds per-process based
338+
// on the time of the current + next window, we need them sorted in ASC
339+
// order.
340+
const processWindowValues = [...processWindows.values()].flat().sort((a, b) => {
341+
return a.window.min - b.window.min;
342+
});
337343
for (let i = 0; i < processWindowValues.length; i++) {
338344
const currentWindow = processWindowValues[i];
339345
const nextWindow = processWindowValues[i + 1];

0 commit comments

Comments
 (0)