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.

fix(gates): a package that draws slowly is not a package that never started

esenginea9bf578ab6ef
diff --git a/desktop/scripts/launch-export.mjs b/desktop/scripts/launch-export.mjs
index b3da22fec..1faddbd1d 100644
--- a/desktop/scripts/launch-export.mjs
+++ b/desktop/scripts/launch-export.mjs
@@ -150,7 +150,12 @@ async function main() {
await win.webContents.session.clearCache();
const errors = [];
+ // Every line, not just the angry ones: when a package never draws, what it got
+ // through before stopping is the whole diagnosis, and none of it says "error".
+ const recent = [];
const stop = onRendererConsole(win.webContents, (msg) => {
+ recent.push(msg.slice(0, 200));
+ if (recent.length > 12) recent.shift();
if (/error|uncaught|failed/i.test(msg)) errors.push(msg.slice(0, 300));
if (msg.startsWith('[engine]') || logRe?.test(msg)) console.log(` ${msg}`);
});
@@ -160,20 +165,21 @@ async function main() {
// Wait for a real frame rather than a wall-clock guess: the engine paints when
// its wasm and assets are in, which is exactly the part a package can get wrong.
- const painted = await win.webContents.executeJavaScript(`
+ const paint = await win.webContents.executeJavaScript(`
new Promise((resolve) => {
const deadline = Date.now() + ${TIMEOUT};
let frames = 0;
const tick = () => {
const c = document.querySelector('canvas');
if (c && c.width > 0 && c.height > 0) frames++;
- if (frames >= ${SETTLE}) return resolve(true);
- if (Date.now() > deadline) return resolve(false);
+ if (frames >= ${SETTLE}) return resolve({ ok: true, frames });
+ if (Date.now() > deadline) return resolve({ ok: false, frames });
requestAnimationFrame(tick);
};
requestAnimationFrame(tick);
})
- `).catch((e) => { errors.push(String(e)); return false; });
+ `).catch((e) => { errors.push(String(e)); return { ok: false, frames: -1 }; });
+ const painted = paint.ok;
// Drive the game, then let it run on.
if (painted && INPUT) {
@@ -200,7 +206,18 @@ async function main() {
const ok = painted && live && errors.length === 0;
console.log(`${ok ? '✓' : '✗'} ${path.basename(DIR)} — painted=${painted} live=${live} errors=${errors.length}`);
for (const e of errors.slice(0, 5)) console.log(` ${e}`);
- if (!painted) console.log(' no canvas ever sized — the package did not start');
+ if (!painted) {
+ // How far it got, rather than "it did not start": a package drawing one slow
+ // frame a second on a software rasteriser reaches neither, and only one of
+ // those two sentences sends you looking in the right place.
+ console.log(` ${paint.frames} of ${SETTLE} settled frames within ${TIMEOUT}ms`);
+ const diag = await win.webContents.executeJavaScript(`(() => {
+ const c = document.querySelector('canvas');
+ return JSON.stringify({ ready: document.readyState, canvas: !!c, w: c ? c.width : 0, h: c ? c.height : 0 });
+ })()`).catch((e) => `unreadable: ${e}`);
+ console.log(` ${diag}`);
+ for (const l of recent) console.log(` · ${l}`);
+ }
if (painted && !live && !has('allow-flat')) console.log(' one flat colour — it started and drew nothing');
app.exit(ok || (live === false && has('allow-flat') && painted && !errors.length) ? 0 : 1);
}
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index 42b1c4185..a47d1f08f 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -199,6 +199,10 @@ export const GOLDEN = [
// by its import's own products, the sun casts it onto the panel behind it, and
// the baked environment is what its metal reflects.
interactGap: 'a lighting showcase has nothing to drive; what it certifies is what reaches the frame',
+ // The only pr-tier project with a shadow pass, and a runner with no GPU
+ // rasterises that 1024² map in software: its frames cost about a second each,
+ // so the settle window has to be minutes rather than the 2D default.
+ launchTimeoutMs: 180_000,
// The pose is HELD rather than played, so a point means one thing rather than
// one moment. Measured on the package; each was checked by breaking the
// feature it is about and watching it, and only it, go.
@@ -495,6 +499,16 @@ export function webPixels(g) {
return g?.webPixels ?? null;
}
+/**
+ * How long a package gets to reach a settled frame, when the default is not
+ * enough. The default was measured on 2D games; a scene with a shadow pass costs
+ * a second a frame on the software rasteriser a runner without a GPU falls back
+ * to, and thirty settle frames do not fit in thirty seconds.
+ */
+export function launchTimeoutFor(g) {
+ return g?.launchTimeoutMs ?? null;
+}
+
/** Why a project's points were skipped on this host, for the run to print. */
export function desktopPixelsSkip(g, host) {
if (!g?.desktopPixels || !g.desktopPixelsHosts || g.desktopPixelsHosts.includes(host)) return null;
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index a38cc370a..0236ce35a 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -19,7 +19,7 @@
import { spawnSync } from 'node:child_process';
import { mkdirSync, rmSync, readFileSync, existsSync } from 'node:fs';
import path from 'node:path';
-import { atTier, projectDir, parityFor, interactFor, audioFor, suspendFor, safeAreaFor, atlasFor, webPixels, ROOT } from './goldenProjects.mjs';
+import { atTier, projectDir, parityFor, interactFor, audioFor, suspendFor, safeAreaFor, atlasFor, webPixels, launchTimeoutFor, ROOT } from './goldenProjects.mjs';
import { frameDistance, frameCellMax, readPNG } from './frameCompare.mjs';
import { retryOnDeadGpu, deadGpuVerdict } from './lib/deadGpu.mjs';
@@ -262,9 +262,11 @@ for (const { id, target } of pairs) {
}
const packagePng = SHOTS ? path.join(SHOTS, `${id}-${target}.png`) : path.join(WORK, `${id}-${target}.png`);
+ const timeoutMs = launchTimeoutFor(golden);
const launch = launchPackage(id, target, [
'--dir', out, '--out', packagePng,
...(editor ? ['--w', String(editor.w), '--h', String(editor.h)] : []),
+ ...(timeoutMs ? ['--timeout', String(timeoutMs)] : []),
]);
const line = (launch.stdout || '').split('\n').find((l) => l.startsWith('✓') || l.startsWith('✗')) ?? '';
@@ -274,7 +276,9 @@ for (const { id, target } of pairs) {
: line || 'launch failed';
results.push({ id, target, stage: 'launch', ok: false, why });
console.log(`✗ ${id} ${target} — ${why}`);
- for (const l of (launch.stdout || '').split('\n').slice(-6)) if (l.trim()) console.log(` ${l}`);
+ // Deep enough to carry the launcher's own diagnosis of a package that never
+ // drew — six lines cut it off at the headline.
+ for (const l of (launch.stdout || '').split('\n').slice(-20)) if (l.trim()) console.log(` ${l}`);
continue;
}