From 543b052136d3b0e19a5c562c27ba4918903b3c8d Mon Sep 17 00:00:00 2001 From: MelekTaus Date: Tue, 29 Sep 2026 22:48:23 +0200 Subject: [PATCH] Stamp the release in the page for the drag check in e2e 41 (#282) The first CI run after 9cff528 failed e2e 41 again, at the release this time (task 405): the hold was fine for 54 frames, but the first sample after the release was 6.9 units below the hold, over the bound of 3. The test took its release time after the round trip of the mouse event and one more evaluate. The frames in between were missing, so the first counted sample was already about 100 ms into the fall. - The page stamps the release itself with a capturing `pointerup` listener. Held and released samples are split at that stamp. - The fixed bound on the first sample after the release is gone. How far that frame has fallen follows the frame time. Instead every sample in the first 200 ms must stay below the hold and keep falling, which is what "let go at rest" means: no jump, no kick up. - The 200 ms fall still has to be more than 1 and less than 40 units. The comment now says about 25, as measured, instead of under 20. Tests: - e2e 41 on melektaus-atx: 8 of 8 runs ALL PASSED, 21 checks. The first sample came 6 to 42 ms after the stamp. - Counter-check: a release velocity of y -2 instead of 0 in PhysicsSystem makes the body rise to -3510 and the check fails. - Gate on melektaus-atx: 195 files, 2829 tests, CHECK EXIT 0. Co-Authored-By: Claude Opus 5.5 --- tools/e2e/41-physics.mjs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/e2e/41-physics.mjs b/tools/e2e/41-physics.mjs index a83b0442..b7c2e829 100644 --- a/tools/e2e/41-physics.mjs +++ b/tools/e2e/41-physics.mjs @@ -302,6 +302,8 @@ export async function physics(t) { () => false, ); // Every frame recorded in the page, so the count follows the frames and not the round trips. + // The page also stamps the release itself: a stamp taken after the round trip came frames late, + // and the first sample after it was already 7 units into the fall on the WSL runner. await evaluate(`(() => { const out = (window.__dragSamples = []); const sample = () => { @@ -309,29 +311,36 @@ export async function physics(t) { if (!window.__dragSamplesDone) requestAnimationFrame(sample); }; window.__dragSamplesDone = false; + window.__dragLetGo = undefined; + window.addEventListener('pointerup', () => (window.__dragLetGo = performance.now()), { + capture: true, + once: true, + }); requestAnimationFrame(sample); })()`); await sleep(1000); await shot('41-drag-while-playing'); const dragInfo = { grab, selected: (await state()).selection?.objectId }; - const holdEnd = await evaluate('performance.now()'); await mouse('mouseReleased', to.x, to.y, 'left'); - const letGo = await evaluate('performance.now()'); await sleep(300); await evaluate('window.__dragSamplesDone = true'); const dragSamples = await json('window.__dragSamples'); + const letGo = await evaluate('window.__dragLetGo'); const log = (await json('__gm.world()'))?.log ?? []; await stop(); - const held = dragSamples.filter((s) => s.t < holdEnd).map((s) => s.y); + const held = dragSamples.filter((s) => s.t < letGo).map((s) => s.y); const released = dragSamples.filter((s) => s.t >= letGo); - // 200 ms of free fall from rest is under 20 below the hold, a body let go at speed is not. - const fell = released.filter((s) => s.t - letGo <= 200).at(-1)?.y; + // 200 ms of free fall from rest is about 25 below the hold, a body let go at speed is not. + const falling = released.filter((s) => s.t - letGo <= 200).map((s) => s.y); + const fell = falling.at(-1); check( 'a body dragged while playing hangs where the pointer holds it and is let go at rest', arrived && held.length >= 30 && held.every((y) => Math.abs(y - target) < 1.5) && - Math.abs(released[0]?.y - target) < 3 && + // Let go it only falls: no jump above the hold, no kick up. How far the first frame after + // the release has already fallen follows the frame time, so that is not a bound here. + falling.every((y, i) => y > target - 1.5 && (i === 0 || y >= falling[i - 1] - 0.01)) && fell > target + 1 && fell < target + 40 && !log.some((line) => line.includes('moved directly')), @@ -339,7 +348,8 @@ export async function physics(t) { target, arrived, held: { frames: held.length, first: held[0], last: held.at(-1) }, - released: released.slice(0, 3).map((s) => s.y), + stamped: typeof letGo === 'number', + released: released.slice(0, 3).map((s) => [Math.round(s.t - letGo), s.y]), fell, log, dragInfo,