Time the arrival reveal from the frame that shows the row again

The reveal probe hides a contact's row, waits for frames that draw it
hidden, and shows it again. Those hidden frames are the probe's setup:
they now restart the reveal's clock and deadline and are reported as
hiddenMs. The row stays hidden for two drawn frames, past the frame that
follows the settle frame, so the reveal is timed on an ordinary frame
instead of on whether that frame was pipelined.
This commit is contained in:
Sameh Khamis committed 2026-11-10 14:50:48 -08:00
1 parent 4972aac345
commit 6c49ffe825
3 files changed
+68 -9

No files matched your search

+15 -3
View File
@@ -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;
@@ -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 });