mirror of
https://github.com/block/buzz.git
synced 2026-11-09 02:41:57 +00:00
fix(desktop): stamp the start mark at the anchored input event
Blind-review round 18 (Opus xhigh) finding: 26ee8982b moved the measure's origin to the input event's timeStamp but left the start mark at handler-dispatch time, so the Performance panel showed the measure beginning before its own start mark by the input delay — two different switch durations from one instrument. The mark now carries startTime: startedAt, pinned by asserting mark and measure share the anchor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Max Lampert <maxwell@squareup.com>
This commit is contained in:
@@ -471,6 +471,9 @@ test("the trace anchors at the input event, not handler dispatch", async () => {
|
||||
globalThis.window.event = { timeStamp: performance.now() - 550 };
|
||||
begin("aaaa1111aaaa1111");
|
||||
delete globalThis.window.event;
|
||||
const startMark = performance
|
||||
.getEntriesByName("buzz:channel-switch:start")
|
||||
.at(-1);
|
||||
settle("aaaa1111aaaa1111");
|
||||
flush();
|
||||
const measure = performance
|
||||
@@ -481,6 +484,9 @@ test("the trace anchors at the input event, not handler dispatch", async () => {
|
||||
measure.duration >= 550,
|
||||
`input delay must be inside the measure (got ${measure.duration})`,
|
||||
);
|
||||
// The mark and the measure must share the anchor, or the Performance
|
||||
// panel shows two different switch durations for the same switch.
|
||||
assert.equal(startMark?.startTime, measure.startTime);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -280,7 +280,13 @@ export function beginChannelSwitchTrace(channelId: string): void {
|
||||
performance.clearMarks(CHANNEL_SWITCH_START_MARK);
|
||||
performance.clearMarks(CHANNEL_SWITCH_SETTLED_MARK);
|
||||
performance.clearMeasures(CHANNEL_SWITCH_MEASURE);
|
||||
performance.mark(CHANNEL_SWITCH_START_MARK, { detail: { channelId } });
|
||||
// startTime keeps the mark on the same anchor as the measure — without it
|
||||
// the Performance panel would show the measure starting before its own
|
||||
// start mark by the input delay.
|
||||
performance.mark(CHANNEL_SWITCH_START_MARK, {
|
||||
detail: { channelId },
|
||||
startTime: startedAt,
|
||||
});
|
||||
}
|
||||
|
||||
export function markChannelSwitchRouteCommit(channelId: string): void {
|
||||
|
||||
Reference in New Issue
Block a user