diff --git a/scripts/track-regression.mjs b/scripts/track-regression.mjs index ec5f1e4d2..42772cd2b 100644 --- a/scripts/track-regression.mjs +++ b/scripts/track-regression.mjs @@ -2882,10 +2882,14 @@ async function main() { // angle — a wrong first reveal, or a wrong settle frame before a // reveal timeout — never does. // - // The reveal: the row is hidden right after the settle frame, a frame + // The reveal: the row is hidden right after the settle frame, frames // must actually draw it hidden, and only then is it shown again, so // the frame measured is the first one that draws it after a hidden - // frame. + // frame. It stays hidden for two drawn frames, past the frame that + // follows the settle frame, so the reveal is timed on an ordinary + // frame rather than on whether that one was pipelined; each hidden + // frame restarts the reveal's clock, and the setup is `hiddenMs`. + const REVEAL_HIDDEN_FRAMES = 2; let revealArmed = false; let hiddenFrames = 0; const observed = await observeArrivalRotationWithRetry({ @@ -2910,11 +2914,15 @@ async function main() { }, read() { const sample = drawnError(); - // A frame drew it hidden: show it again for the next one. + // A frame drew it hidden: after the last one, show it again for + // the next frame; the reveal is measured from here. if (revealArmed && sample.shown === false) { hiddenFrames += 1; - revealArmed = false; - setIconShown(id, { shown: true }); + if (hiddenFrames >= REVEAL_HIDDEN_FRAMES) { + revealArmed = false; + setIconShown(id, { shown: true }); + } + return { ...sample, revealStartsNow: true }; } return sample; }, @@ -2933,7 +2941,7 @@ async function main() { }; }); const fmtArr = (a) => (!a ? `no result (${arrival?.error || 'phase error'})` : a.error ? `${a.error}; ${arrivalAngleViolated(a) ? 'angle violation (not retried); ' : ''}${Number.isFinite(a.dMoveEnd) ? `settle-err=${(a.dMoveEnd * 180 / Math.PI).toFixed(1)}° ` : ''}${Number.isFinite(a.dReveal) ? `reveal-err=${(a.dReveal * 180 / Math.PI).toFixed(1)}° ` : ''}elapsed=${Number(a.elapsedMs).toFixed(1)} ms attempts=${a.attempts}` - : `settle-err=${(a.dMoveEnd * 180 / Math.PI).toFixed(1)}° reveal-err=${(a.dReveal * 180 / Math.PI).toFixed(1)}° shown=${a.shown} flipFrame=${a.flipFrame} settle=${a.moveEndMs.toFixed(1)} ms reveal=${a.revealMs.toFixed(1)} ms total=${a.elapsedMs.toFixed(1)} ms attempts=${a.attempts} hasModel=${a.hasModel}`); + : `settle-err=${(a.dMoveEnd * 180 / Math.PI).toFixed(1)}° reveal-err=${(a.dReveal * 180 / Math.PI).toFixed(1)}° shown=${a.shown} flipFrame=${a.flipFrame} settle=${a.moveEndMs.toFixed(1)} ms reveal=${a.revealMs.toFixed(1)} ms hidden=${a.hiddenMs.toFixed(1)} ms total=${a.elapsedMs.toFixed(1)} ms attempts=${a.attempts} hasModel=${a.hasModel}`); record('arrival: the drawn nose is right on the settle frame and the first reveal, flights', arrivalRotationPassed(arrival.flights), fmtArr(arrival.flights)); record('arrival: the drawn nose is right on the settle frame and the first reveal, military', diff --git a/src/tooling/trackArrivalObservation.mjs b/src/tooling/trackArrivalObservation.mjs index ce39801f0..9797bfdc4 100644 --- a/src/tooling/trackArrivalObservation.mjs +++ b/src/tooling/trackArrivalObservation.mjs @@ -21,7 +21,10 @@ export const ARRIVAL_MAX_ATTEMPTS = 2; * The settle deadline starts when moveEnd is forced, before its rotation * baseline; the reveal deadline restarts at the settle frame, which is where * the contact is hidden. `read` snapshots visibility and rotation error - * against the current position. + * against the current position. A hidden sample carrying `revealStartsNow` + * (a frame drew the contact hidden and it was just shown again) restarts the + * reveal's clock and deadline there: the frames spent drawing it hidden are + * the probe's setup, reported as `hiddenMs`, not part of the reveal. */ export function observeArrivalRotation({ scene, @@ -37,6 +40,9 @@ export function observeArrivalRotation({ let phaseStartedAt = startedAt; let moveEnd = null; let moveEndMs = null; + // Where the reveal is measured from: the settle frame, or the frame a + // `revealStartsNow` sample marks. + let revealFromMs = null; let revealFrames = 0; let done = false; let remove; @@ -85,12 +91,17 @@ export function observeArrivalRotation({ if (moveEnd === null) { moveEnd = sample; moveEndMs = elapsedMs; + revealFromMs = elapsedMs; phaseStartedAt = at; armDeadline(); startReveal(); } else { revealFrames++; - if (sample.shown) { + if (!sample.shown && sample.revealStartsNow) { + revealFromMs = elapsedMs; + phaseStartedAt = at; + armDeadline(); + } else if (sample.shown) { // Keep the FIRST visible result, including a wrong angle. Never // wait for a subsequent tick to repair a failed reveal. finish({ @@ -99,7 +110,8 @@ export function observeArrivalRotation({ shown: sample.shown, flipFrame: revealFrames, moveEndMs, - revealMs: elapsedMs - moveEndMs, + revealMs: elapsedMs - revealFromMs, + hiddenMs: revealFromMs - moveEndMs, elapsedMs, }); return; diff --git a/src/tooling/trackArrivalObservation.test.mjs b/src/tooling/trackArrivalObservation.test.mjs index de8b783fc..eb53b24cc 100644 --- a/src/tooling/trackArrivalObservation.test.mjs +++ b/src/tooling/trackArrivalObservation.test.mjs @@ -88,6 +88,45 @@ test('80 ms fleet scheduling passes after more than four fast rendered frames', assert.equal(f.resources.moveEnds, 1); }); +test('a reveal is measured from the frame that drew the contact hidden', async () => { + const f = fixture(); + f.frame(8, { shown: true, rotationError: 0 }); + // The hidden frame waits behind a slow swap; the probe then shows it again. + f.frame(300, { shown: false, revealStartsNow: true }); + f.frame(390, { shown: true, rotationError: 0, revealStartsNow: false }); + const result = await f.observation; + assert.equal(result.flipFrame, 2); + assert.equal(result.moveEndMs, 8); + assert.equal(result.hiddenMs, 292); + assert.equal(result.revealMs, 90); + assert.equal(result.elapsedMs, 390); + assert.equal(arrivalRotationPassed(result), true); + assert.equal(f.resources.timers, 0); +}); + +test('the reveal deadline restarts at the frame that drew the contact hidden', async () => { + const f = fixture(); + f.frame(8, { shown: true, rotationError: 0 }); + f.frame(400, { shown: false, revealStartsNow: true }); + // 500 ms after the settle frame, but only 200 ms into the reveal. + f.expire(600); + f.frame(850, { shown: true, rotationError: 0, revealStartsNow: false }); + const result = await f.observation; + assert.equal(result.error, undefined); + assert.equal(result.revealMs, 450); + assert.equal(arrivalRotationPassed(result), true); +}); + +test('a reveal without a hidden-frame mark is measured from the settle frame', async () => { + const f = fixture(); + f.frame(8, { shown: true, rotationError: 0 }); + f.frame(16, { shown: false }); + f.frame(96, { shown: true, rotationError: 0 }); + const result = await f.observation; + assert.equal(result.revealMs, 88); + assert.equal(result.hiddenMs, 0); +}); + test('a wrong first visible angle fails even if the next frame corrects it', async () => { const f = fixture(); f.frame(8, { shown: true, rotationError: 0 });