01. Millisecond-Accurate Paint Sync Calibration
Standard browser reaction timers initiate time-captions during a state trigger, letting the browser queue and paint the visual state change asynchronously. This introduces a variable latency jitter of 8ms to 32ms depending on GPU scheduling and screen refresh rates.
CogniArena resolves this by measuring reaction triggers using a
double-nested requestAnimationFrame (rAF) loop. The start timestamp
is locked only when the browser confirms the paint buffer has updated, matching
real-world photon emission delays.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
startTime.current = performance.now();
});
});