test(perf): record the horizontal move of layout-shift sources

J2's 0.233 shift on the runner moves main.workspace-content, the header
search field and the header actions with deltaY and deltaHeight 0, so
the move is horizontal and the probe could not show it. Sources now also
carry deltaX and deltaWidth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 5.5 committed 2026-10-06 12:37:11 +02:00
1 parent 655f54b362
commit f6af34af5f
6 files changed
+36 -15

No files matched your search

@@ -341,6 +341,8 @@ test('keeps summing shifts without recent input after the first-card cutoff unti
[
{
deltaHeight: 0,
deltaWidth: 0,
deltaX: 0,
deltaY: -240,
node: 'lib-dashboard-rail[data-test-id="dashboard-favorites-rail"]',
},
@@ -800,9 +802,9 @@ test('drops performance entries from before the click and keeps recent-input shi
hadRecentInput: true,
sources: [
{
currentRect: { height: 40, y: 152 },
currentRect: { height: 40, width: 300, x: 48, y: 152 },
node: fixture.card,
previousRect: { height: 40, y: 100 },
previousRect: { height: 40, width: 320, x: 0, y: 100 },
},
],
startTime: now(),
@@ -835,10 +837,14 @@ test('drops performance entries from before the click and keeps recent-input shi
state.shifts.map((shift) => [
shift.hadRecentInput,
shift.value,
shift.sources.map((source) => source.deltaY),
shift.sources.map((source) => [
source.deltaX,
source.deltaY,
source.deltaWidth,
]),
]),
[
[true, 0.25, [52]],
[true, 0.25, [[48, 52, -20]]],
[false, 0.125, []],
]
);
@@ -17,9 +17,9 @@ export interface FakeEntry {
entryType: string;
hadRecentInput?: boolean;
sources?: {
currentRect: { height: number; y: number };
currentRect: { height: number; width?: number; x?: number; y: number };
node: unknown;
previousRect: { height: number; y: number };
previousRect: { height: number; width?: number; x?: number; y: number };
}[];
startTime: number;
value?: number;
@@ -171,7 +171,7 @@ export interface JourneyRendererProbeShift {
readonly hadRecentInput: boolean;
/** Entry start minus the journey start (navigation start for J1). */
readonly sinceStartMs: number;
/** `tag.class[data-test-id]` and the vertical move of each source. */
/** `tag.class[data-test-id]` and the move of each source. */
readonly sources: JourneyRendererProbeLateShift['sources'];
readonly value: number;
}
@@ -179,9 +179,11 @@ export interface JourneyRendererProbeShift {
export interface JourneyRendererProbeLateShift {
/** Entry start minus the first-card terminal epoch. */
readonly afterFirstCardMs: number;
/** `tag.class[data-test-id]` and the vertical move of each source. */
/** `tag.class[data-test-id]` and the move of each source. */
readonly sources: readonly {
readonly deltaHeight: number;
readonly deltaWidth: number;
readonly deltaX: number;
readonly deltaY: number;
readonly node: string;
}[];
@@ -558,10 +560,11 @@ export function journeyRendererProbeScript(
state.idle.status = 'done';
}, idle.durationMs);
};
type ShiftRect = { height: number; width?: number; x?: number; y: number };
type LateShiftSource = {
currentRect?: { height: number; y: number };
currentRect?: ShiftRect;
node?: Node | null;
previousRect?: { height: number; y: number };
previousRect?: ShiftRect;
};
const describeSource = (source: LateShiftSource) => {
const node = source.node;
@@ -578,9 +581,13 @@ export function journeyRendererProbeScript(
}
const before = source.previousRect;
const after = source.currentRect;
const delta = (key: keyof ShiftRect) =>
before && after ? (after[key] ?? 0) - (before[key] ?? 0) : 0;
return {
deltaHeight: before && after ? after.height - before.height : 0,
deltaY: before && after ? after.y - before.y : 0,
deltaHeight: delta('height'),
deltaWidth: delta('width'),
deltaX: delta('x'),
deltaY: delta('y'),
node: label,
};
};
@@ -65,6 +65,8 @@ function measurement(
sources: [
{
deltaHeight: 0,
deltaWidth: 0,
deltaX: 0,
deltaY: -240,
node: 'section.dashboard-rail',
},
@@ -211,6 +213,8 @@ test('maps the probe, IPC capture and main counters to exact counters and spawn-
sources: [
{
deltaHeight: 0,
deltaWidth: 0,
deltaX: 0,
deltaY: -240,
node: 'section.dashboard-rail',
},
@@ -66,6 +66,8 @@ function measurement(
sources: [
{
deltaHeight: 0,
deltaWidth: 0,
deltaX: 0,
deltaY: 52,
node: 'div.content[data-test-id="category-list"]',
},
@@ -168,6 +170,8 @@ test('maps the click-started probe, IPC window and mock ledger to exact counters
sources: [
{
deltaHeight: 0,
deltaWidth: 0,
deltaX: 0,
deltaY: 52,
node: 'div.content[data-test-id="category-list"]',
},
+3 -3
View File
@@ -175,8 +175,8 @@ closed or closed before the cutoff. J2's probe has no settle window
most 20): the time after the first card, the value and, for each source the
browser attributes the shift to, the node (`tag.class[data-test-id]`; a
component host such as `lib-dashboard-rail` takes its first child's test id)
and its vertical move. A late shift can therefore be traced to its component
from the summary alone.
and its move (`deltaX`, `deltaY`, `deltaWidth`, `deltaHeight`). A late shift
can therefore be traced to its component from the summary alone.
First local measurement (macOS, 2026-09-29, `master` with #1738): all
windows closed on `quiet`, `renderer.layoutShiftScore` stayed 0, and
@@ -719,7 +719,7 @@ strings and stream paths carry credentials and are never stored.
| `renderer.ipcCallsToFirstPage` | Bridge `start` trace events between the start and end sentinels, counted by a second `journey-main-ipc-capture.ts` instance installed with `startSentinelId`. Calls before the start marker are tallied separately (`callsBeforeStart`); a start marker that is missing, repeated or received after the end sentinel fails the iteration. |
| `renderer.domMutationsToFirstPage` | `MutationRecord`s from the click until the terminal batch. Records produced before the click (hover, settling) are taken from the observer at the start and counted under `evidence.settle` instead. |
| `renderer.cdTicksToFirstPage` | `ApplicationRef` ticks from the click until the terminal batch: the counter's running total read in the capture-phase click listener, before the app handles the click, subtracted from its value at the terminal batch (see [Change-detection ticks](#change-detection-ticks)). |
| `renderer.layoutShiftScore` | Sum of all `layout-shift` entries from the click until the post-paint cutoff, rounded to three decimals. Unlike J1 it includes entries with `hadRecentInput === true`: the journey is a response to the click and runs inside the 500 ms input window, so the CLS filter would always read 0. The split is under `evidence.layoutShift`. |
| `renderer.layoutShiftScore` | Sum of all `layout-shift` entries from the click until the post-paint cutoff, rounded to three decimals. Unlike J1 it includes entries with `hadRecentInput === true`: the journey is a response to the click and runs inside the 500 ms input window, so the CLS filter would always read 0. The split is under `evidence.layoutShift`, and `evidence.layoutShift.shifts` lists the first 20 counted shifts with their value, `hadRecentInput`, time since the click and the nodes that moved (`tag.class[data-test-id]` and their `deltaX`, `deltaY`, `deltaWidth` and `deltaHeight`, as J1's late shifts). |
| `renderer.longTasks` | `longtask` entries over 50 ms whose time range overlaps the window from the click to the cutoff. The task that dispatches the click began before the event's timestamp and still counts; buffered J1 tasks that ended before the click are dropped. Evidence until it is shown to be stable on the CI runner, as for J1. |
| `main.mockHttpRequestsToSettled` | Requests the proxy received from the click until, after the terminal batch, no new request had arrived for 1 s and none was in flight (a response slower than that, and what it triggers, stays inside the window). The window ends at the ledger position read by that accepted quiet sample; a request arriving after it was never seen in flight, so it goes to `evidence.httpRequestsAfterSettledByRoute` instead of the counter. The ledger is read 1 s after that sample, so that late traffic is actually observed. The window starts at the renderer's click stamp, the same boundary as every other J2 counter, not when Playwright began its actionability checks; the proxy stamps requests with the test process's wall clock, and both processes read the same host clock. Bounding by the terminal would compare the test process's clock with the renderer's, so the count up to the terminal epoch is evidence only (`evidence.httpRequestsToFirstPage`); `evidence.httpRequestsByRoute` names the requests. |