Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(debug): the remote-capture check does not read one clock step as a cost

esenginee8327559eda3
diff --git a/tools/verify-remote-capture.mjs b/tools/verify-remote-capture.mjs
index fd98595b2..74156fc7f 100644
--- a/tools/verify-remote-capture.mjs
+++ b/tools/verify-remote-capture.mjs
@@ -146,8 +146,11 @@ try {
await new Promise((r) => setTimeout(r, 2000));
const cost = await server.query(target.id, 'stats');
const perFrame = cost?.frames > 0 ? cost.agentMs / cost.frames : NaN;
- check(typeof cost?.agentMs === 'number' && cost.frames > 0 && perFrame <= 0.5,
- `the debug channel cost the device ${cost?.agentMs?.toFixed(3)} ms over ${cost?.frames} frame(s) — ${perFrame.toFixed(4)} ms a frame (budget 0.5)`);
+ // A runner that draws a frame or two a second, on a clock that steps by 1 ms,
+ // reads one step over one frame as 1 ms a frame: that is the clock, not a cost.
+ const belowClock = typeof cost?.clockMs === 'number' && cost.agentMs <= cost.clockMs;
+ check(typeof cost?.agentMs === 'number' && cost.frames > 0 && (perFrame <= 0.5 || belowClock),
+ `the debug channel cost the device ${cost?.agentMs?.toFixed(3)} ms over ${cost?.frames} frame(s) — ${perFrame.toFixed(4)} ms a frame (budget 0.5; clock step ${cost?.clockMs})`);
const tree = (await server.query(target.id, 'snapshot', { selectedId: null, withTree: true }))?.tree;
const ship = tree?.entities.find((e) => e.name === 'Ship');