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.

ci(verify): the second backend gets a runner of its own, and a budget

yhhd3d290aa4a5e
diff --git a/.github/actions/render-host/action.yml b/.github/actions/render-host/action.yml
new file mode 100644
index 000000000..f195a0283
--- /dev/null
+++ b/.github/actions/render-host/action.yml
@@ -0,0 +1,29 @@
+name: Editor host from this run's engine
+description: Stage the wasm this run built into the editor host, with the SDK and the renderer bundle built against it.
+
+# Every job that measures pixels needs the same four steps between the artifact
+# and a runnable host. Two jobs do, and a second copy of them is a copy that
+# drifts — one of them would end up measuring an engine the other never built.
+runs:
+ using: composite
+ steps:
+ - name: Download web wasm artifact
+ uses: actions/download-artifact@v8
+ with:
+ name: wasm-web
+ path: build/wasm/web/
+
+ - name: Build SDK
+ shell: bash
+ run: pnpm --filter ./sdk build
+
+ - name: Stage wasm for the editor host
+ shell: bash
+ run: |
+ mkdir -p desktop/public/wasm
+ cp build/wasm/web/* desktop/public/wasm/
+
+ - name: Build editor renderer bundle
+ shell: bash
+ working-directory: desktop
+ run: pnpm exec vite build
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e5e0dae6a..f617e2726 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -280,23 +280,7 @@ jobs:
- uses: ./.github/actions/setup
- - name: Download web wasm artifact
- uses: actions/download-artifact@v8
- with:
- name: wasm-web
- path: build/wasm/web/
-
- - name: Build SDK
- run: pnpm --filter ./sdk build
-
- - name: Stage wasm for the editor host
- run: |
- mkdir -p desktop/public/wasm
- cp build/wasm/web/* desktop/public/wasm/
-
- - name: Build editor renderer bundle
- working-directory: desktop
- run: pnpm exec vite build
+ - uses: ./.github/actions/render-host
# Twin coverage guard: every fixture AND example .esshader must carry its
# WGSL twin (hand-written, generated, or switch-skipped) — a twin-less shader
@@ -323,30 +307,6 @@ jobs:
# --no-build: the renderer bundle is already built two steps up.
run: node tools/verify-render.mjs --tier pr --no-build
- # Third attempt at the second backend, starting from what the first two bought:
- # ICDs are not the missing half (Dawn came up with mesa's eight installed),
- # the GPU process is — it died before any scene drew, on every retry. Two
- # things are new. The GPU process runs its own sandbox, which
- # ELECTRON_DISABLE_SANDBOX does not reach, so it is disabled in the harness;
- # and the adapter asked for is Electron's own bundled SwiftShader, which is
- # what 85 scenes passed on locally, where the last run took mesa's lavapipe.
- #
- # That answered it: the process comes up once its own sandbox is off, and one
- # scene drew. So the list is the PR tier now, which is the first time these
- # gates run anywhere but a developer's machine — three of this month's bugs
- # were visible only here (a shadow map upside down, a shader language asked
- # for as the wrong one, a twin naming what it never declared).
- #
- # Still informational for one more run: sixty-four scenes on a software
- # rasterizer is a different question from one, and a tolerance that only ever
- # met this machine's GPU should say so without gating anyone. It comes off
- # when the whole tier is green here.
- - name: Second backend, PR tier (informational)
- continue-on-error: true
- env:
- ESTELLA_VERIFY_WEBGPU_ADAPTER: swiftshader
- run: node tools/verify-render.mjs --tier pr --backend webgpu --no-build
-
- name: Run MCP end-to-end
working-directory: desktop
env:
@@ -384,13 +344,38 @@ jobs:
ELECTRON_DISABLE_SANDBOX: '1'
run: xvfb-run -a node tools/verify-legacy.mjs --tier pr
- # The SAME pixel assertions on the WebGPU backend — Dawn renders through the
- # bundled SwiftShader Vulkan (--use-webgpu-adapter=swiftshader), so a GPU-less
- # runner verifies the second backend for real: WGSL twins, the reflected
- # material path, the editor grid, and the async readback (material preview).
- # No WebGPU step: Dawn gets no adapter on a GitHub runner, and the ten scenes
- # that declare the second backend say so in tools/renderScenes.mjs (WEBGPU_GAP)
- # rather than through a step that cannot pass.
+ # The same scenes on the second backend, on a runner of its own.
+ #
+ # Informational is a statement about the VERDICT, not about the cost: sixty-four
+ # scenes on a software Vulkan cost more than half an hour, and spending that
+ # inside the gate job spends the budget the gates need — the editor, golden and
+ # released-project checks are what stopped running for it. Its own job answers
+ # the same question in parallel, and the runner keeps its own budget so the
+ # answer is a report rather than a runner killed at the ceiling.
+ verify-render-webgpu:
+ name: Render verify (second backend)
+ runs-on: ubuntu-latest
+ needs: build-emscripten
+ # The runner stops at its own 45-minute budget and prints what it never
+ # reached; this is that, plus the one scene it may already be retrying
+ # through a dead GPU when the budget runs out.
+ timeout-minutes: 75
+ continue-on-error: true
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - uses: ./.github/actions/setup
+
+ - uses: ./.github/actions/render-host
+
+ # Electron's own bundled SwiftShader: the runner installs no Vulkan driver,
+ # and it is the adapter the tier passes on locally.
+ - name: Second backend, PR tier
+ env:
+ ESTELLA_VERIFY_WEBGPU_ADAPTER: swiftshader
+ run: node tools/verify-render.mjs --tier pr --backend webgpu --no-build --budget 45
+
# The native runtime, judged by pixels on a machine with no GPU.
#
# Until the desktop host existed the native runtime could only be checked on a
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjs
index dd906a88f..93063d9e2 100644
--- a/desktop/scripts/headless-verify.mjs
+++ b/desktop/scripts/headless-verify.mjs
@@ -23,6 +23,7 @@
* ESTELLA_VERIFY_SET_FIELD one inspector field written after load (JSON)
* ESTELLA_VERIFY_PICK hit-test a viewport point, asserting the entity (JSON)
* ESTELLA_VERIFY_ORBIT turn the editor eye before capture ("yaw,pitch" degrees)
+ * ESTELLA_VERIFY_TIMEOUT_MS how long this run may take before it reports one
*/
import { app, BrowserWindow } from 'electron';
import http from 'node:http';
@@ -623,4 +624,7 @@ app.whenReady().then(async () => {
}
});
-setTimeout(() => finish({ ok: false, error: 'timeout' }), 45000);
+// A verdict of "it took too long" is one this process can report; the runner
+// kills it a launch margin later, and that one names no scene.
+const TIMEOUT_MS = Number(process.env.ESTELLA_VERIFY_TIMEOUT_MS) || 45000;
+setTimeout(() => finish({ ok: false, error: `timeout after ${TIMEOUT_MS} ms` }), TIMEOUT_MS);
diff --git a/tools/lib/runTool.mjs b/tools/lib/runTool.mjs
index 887e4b261..9ce677558 100644
--- a/tools/lib/runTool.mjs
+++ b/tools/lib/runTool.mjs
@@ -12,11 +12,16 @@ const VIA_SHELL = process.platform === 'win32';
const quote = (arg) => (VIA_SHELL && /[\s"^&|<>()]/.test(arg) ? `"${String(arg).replace(/"/g, '\\"')}"` : arg);
+/** The shell convention for "killed on its deadline", so a caller that reads
+ * only `status` still sees a failure. */
+export const TIMED_OUT = 124;
+
/**
* `spawnSync` with the caller's usual result shape, except that a process which
* never started reports as one: `status` is a failure and the reason is in
* `stderr`. Without that a launch failure arrives as a zero-length output and
- * every caller blames whatever it was about to measure.
+ * every caller blames whatever it was about to measure. `options.timeout` is
+ * spawnSync's, and a process killed on it reports `timedOut`.
*/
export function runTool(cmd, args, options = {}) {
// One string rather than a command plus args: node deprecates the second form
@@ -25,6 +30,12 @@ export function runTool(cmd, args, options = {}) {
? spawnSync([cmd, ...args].map(quote).join(' '), { ...options, shell: true })
: spawnSync(cmd, args, options);
if (!r.error) return r;
+ // A deadline and a launch failure both arrive as `error`, and they are
+ // opposites: one ran too long, the other never ran at all.
+ if (r.error.code === 'ETIMEDOUT') {
+ const late = `${cmd} was killed after ${options.timeout} ms`;
+ return { ...r, status: r.status ?? TIMED_OUT, timedOut: true, stderr: `${r.stderr ?? ''}${late}\n` };
+ }
const why = `${cmd} did not start: ${r.error.code ?? r.error.message}`;
return { ...r, status: r.status ?? 127, stderr: `${r.stderr ?? ''}${why}\n` };
}
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 6742b6bd2..1d70c5d17 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -22,13 +22,21 @@
/** Cheapest tier a scene runs at; tiers are cumulative. */
export const TIERS = ['pr', 'nightly'];
-/** All 85 pass on Electron's bundled SwiftShader, the software adapter a GPU-less
- * runner would use. On a runner given `libvulkan1` + `mesa-vulkan-drivers` Dawn
- * finds an adapter and the GPU process then dies before drawing — the sandbox is
- * the next thing to try. Only the boot log names the adapter. */
-export const WEBGPU_GAP = 'CI runs ONE of them, informationally, while whether the GPU'
- + ' process comes up there is still the open question; all 85 passed on this'
- + ' machine\'s SwiftShader on 2026-08-17 (`--tier nightly --backend webgpu`)';
+/** Electron's own bundled SwiftShader is the adapter a GPU-less runner gets, and
+ * what the whole list passes on locally. Only the boot log names the one a run
+ * actually took. */
+export const WEBGPU_GAP = 'CI runs the pr tier of them on a runner of its own,'
+ + ' informationally and inside a budget — whether that tier fits there, and'
+ + ' passes, is the open question; the 85 that declared it then all passed on'
+ + ' this machine\'s SwiftShader on 2026-08-17 (`--tier nightly --backend webgpu`)';
+
+/**
+ * How long a scene gets to reach a verdict, by backend — the runner hands this
+ * to the scene as its own watchdog and kills the process a launch margin later.
+ * WebGL2 is measured (a 65-scene tier averages 1.4s each); the second backend
+ * rasterises the same frames on a CPU, and every run prints what each took.
+ */
+export const SCENE_WATCHDOG_MS = { webgl2: 45_000, webgpu: 120_000 };
/**
* Every pixel gate. `env` is handed to desktop/scripts/headless-verify.mjs
diff --git a/tools/verify-render.mjs b/tools/verify-render.mjs
index 40b360386..fe0954904 100644
--- a/tools/verify-render.mjs
+++ b/tools/verify-render.mjs
@@ -8,13 +8,12 @@
* first failure: which scenes broke is the useful answer, not which broke first.
*
* node tools/verify-render.mjs --tier pr
- * node tools/verify-render.mjs --tier pr --backend webgpu
+ * node tools/verify-render.mjs --tier pr --backend webgpu --budget 45
* node tools/verify-render.mjs --tier nightly --only spine,video
*/
-import { spawnSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
-import { TIERS, SCENES, scenesAtTier } from './renderScenes.mjs';
+import { TIERS, SCENES, scenesAtTier, SCENE_WATCHDOG_MS } from './renderScenes.mjs';
import { retryOnDeadGpu, deadGpuVerdict } from './lib/deadGpu.mjs';
import { runTool } from './lib/runTool.mjs';
import { requireCurrentEngine } from './lib/engineBuild.mjs';
@@ -31,6 +30,7 @@ const flag = (n, d) => {
const TIER = flag('tier', 'pr');
const ONLY = flag('only', '');
const BACKEND = flag('backend', 'webgl2');
+const BUDGET = flag('budget', '');
const NO_BUILD = argv.includes('--no-build');
// CI runners cannot use the SUID sandbox helper (not root-owned in
// node_modules), and a pixel check does not need it.
@@ -54,6 +54,18 @@ if (!['webgl2', 'webgpu'].includes(BACKEND)) {
console.error(`verify-render: unknown backend "${BACKEND}" (have: webgl2, webgpu)`);
process.exit(2);
}
+if (BUDGET && !(Number(BUDGET) > 0)) {
+ console.error(`verify-render: --budget takes minutes, not "${BUDGET}"`);
+ process.exit(2);
+}
+// Minutes the whole run may spend before it stops and says what it never
+// measured. A tier that outgrows its runner is a report either way; without one
+// the report is a killed process, which names no scene at all.
+const BUDGET_MS = Number(BUDGET || 0) * 60_000;
+const WATCHDOG_MS = SCENE_WATCHDOG_MS[BACKEND];
+// The scene's own watchdog produces a verdict, so this kill is for the launch
+// that never reaches it — a whole electron start-up beyond.
+const LAUNCH_MARGIN_MS = 30_000;
// A scene runs on the second backend only where it says so: the two backends
// agree on most frames and deliberately differ on a couple of tolerances, and
// guessing that per scene is how the WebGPU list became a third copy.
@@ -87,26 +99,44 @@ if (!NO_BUILD) {
}
}
+const seconds = (ms) => `${(ms / 1000).toFixed(1)}s`;
+
function runScene(scene) {
const args = XVFB
? ['-a', 'pnpm', 'exec', 'electron', 'scripts/headless-verify.mjs']
: ['exec', 'electron', 'scripts/headless-verify.mjs'];
+ const at = Date.now();
const r = runTool(XVFB ? 'xvfb-run' : 'pnpm', args, {
cwd: DESKTOP,
encoding: 'utf8',
- env: { ...process.env, ELECTRON_DISABLE_SANDBOX: '1', ...scene.env },
+ timeout: WATCHDOG_MS + LAUNCH_MARGIN_MS,
+ env: {
+ ...process.env,
+ ELECTRON_DISABLE_SANDBOX: '1',
+ ESTELLA_VERIFY_TIMEOUT_MS: String(WATCHDOG_MS),
+ ...scene.env,
+ },
});
const out = `${r.stdout || ''}${r.stderr || ''}`;
return {
ok: r.status === 0,
out,
- verdict: ((r.stdout || '').match(/\[verify:render\][^\n]*/) ?? [''])[0].replace('[verify:render] ', ''),
+ ms: Date.now() - at,
+ verdict: r.timedOut
+ ? 'the run never reached its own watchdog and was killed'
+ : ((r.stdout || '').match(/\[verify:render\][^\n]*/) ?? [''])[0].replace('[verify:render] ', ''),
};
}
const failed = [];
+const unmeasured = [];
+const startedAt = Date.now();
let retried = 0;
-for (const scene of scenes) {
+for (const [index, scene] of scenes.entries()) {
+ if (BUDGET_MS && Date.now() - startedAt >= BUDGET_MS) {
+ for (const rest of scenes.slice(index)) unmeasured.push(rest.id);
+ break;
+ }
// A scene that TAKES the GPU away on purpose owns its own device-loss result;
// everything else shares one retry policy with the golden runner, or the same
// dead runner is a retry in one and a broken engine in the other.
@@ -126,16 +156,20 @@ for (const scene of scenes) {
run = attempt;
}
if (!run.ok) failed.push(scene.id);
- console.log(`${run.ok ? '✓' : '✗'} ${scene.id.padEnd(28)} `
+ console.log(`${run.ok ? '✓' : '✗'} ${scene.id.padEnd(28)} ${seconds(run.ms).padStart(7)} `
+ `${run.gpuDied ? deadGpuVerdict('the scene') : run.verdict}`);
if (!run.ok) {
for (const l of run.out.split('\n').slice(-8)) if (l.trim()) console.log(` ${l}`);
}
}
-console.log(`\nrender ${TIER}: ${scenes.length - failed.length}/${scenes.length} scene(s) drew what they claim`
+const measured = scenes.length - unmeasured.length;
+console.log(`\nrender ${TIER}: ${measured - failed.length}/${measured} scene(s) drew what they claim`
+ + ` in ${seconds(Date.now() - startedAt)}`
+ (retried ? `, ${retried} measured twice (the GPU had died)` : ''));
-if (failed.length) {
- for (const id of failed) console.log(` ✗ ${id}`);
- process.exit(1);
+if (failed.length) for (const id of failed) console.log(` ✗ ${id}`);
+if (unmeasured.length) {
+ console.log(`\nthe ${BUDGET} minute budget ran out: ${unmeasured.length} scene(s) never ran`);
+ for (const id of unmeasured) console.log(` · ${id}`);
}
+if (failed.length || unmeasured.length) process.exit(1);