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(golden): a missing frame says what the attempt printed, and blames the GPU only on evidence

esengine9cc0ff58a6a2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 14824ec92..5a444413d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -714,7 +714,9 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: golden-parity-frames
- path: .golden/*.png
+ path: |
+ .golden/*.png
+ .golden/*.log
include-hidden-files: true
if-no-files-found: warn
retention-days: 7
diff --git a/desktop b/desktop
index c8aeb697b..5c46eeedf 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit c8aeb697bf32ac78641deeca4cba0b830d96e960
+Subproject commit 5c46eeedfb55a361902ad5ede4bdcfa9e8735f8b
diff --git a/tools/lib/deadGpu.mjs b/tools/lib/deadGpu.mjs
index 580a0b3ef..9b6d3a3ed 100644
--- a/tools/lib/deadGpu.mjs
+++ b/tools/lib/deadGpu.mjs
@@ -36,6 +36,31 @@ export function gpuNeverCameUp(output) {
|| /WebGL2 is not available/.test(output);
}
+/**
+ * Evidence a GPU really failed, strong enough to blame it for a run that never
+ * reached a verdict: the engine could not make what it draws through, or WebGL2
+ * was refused. {@link gpuNeverCameUp} is not: its first line prints on every
+ * launch on the Linux runner, and every failure there read as a dead GPU.
+ */
+export function gpuFailed(output) {
+ return engineCouldNotDraw(output) || /WebGL2 is not available/.test(output);
+}
+
+/** Lines every launch on a GPU-less runner prints, whatever happens next. */
+const NOISE = /Exiting GPU process due to errors during initialization|dbus\/|GPU stall due to ReadPixels|Fontconfig|GL Driver Message/;
+
+/**
+ * The lines of a failed attempt that say what happened, for a log that is read on
+ * a runner nobody can open: its errors, timeouts and signals, noise removed, last
+ * few kept. An attempt that printed none says so rather than printing nothing.
+ */
+export function failureLines(output, max = 8) {
+ const lines = String(output ?? '').split('\n').map((l) => l.trim())
+ .filter((l) => l && !NOISE.test(l)
+ && /error|fail|timed out|timeout|exception|fatal|signal|crash|lost|not available|unreachable|refused/i.test(l));
+ return lines.length ? lines.slice(-max) : ['(the attempt printed no error line)'];
+}
+
/**
* Electron never started: no display, a sandbox helper that is not setuid root,
* a binary that is not there. Not the GPU, and not worth six retries — a nightly
@@ -152,13 +177,10 @@ function reachedNoVerdict(last) {
}
/**
- * Run `attempt` until it succeeds, or fails in a way that is the subject's own.
- * `note(noVerdict)` announces each retry.
- *
- * `attempt()` returns `{ ok, output }` plus, where it can tell: `measured` (did
- * this run reach a verdict? one that did has measured something, and its failure
- * is the subject's however loud the log is) and `drew` (did anything reach the
- * screen? a blank frame right after an outage is that outage still settling).
+ * Run `attempt` ({ ok, output, measured?, drew? }) until it succeeds or fails in a way
+ * that is the subject's own; `note(noVerdict, last)` announces each retry. A verdict
+ * that was measured is never retried, and a run that gives up is `gpuDied` only on
+ * {@link gpuFailed}'s evidence.
*/
export function retryOnDeadGpu(attempt, note, stepMs = STEP_MS) {
// A chain that waits for nothing (tests) has no runner to remember across.
@@ -189,5 +211,5 @@ export function retryOnDeadGpu(attempt, note, stepMs = STEP_MS) {
backoff(i, stepMs);
}
}
- return { ...last, retried: true, gpuDied: true };
+ return { ...last, retried: true, gpuDied: gpuFailed(last.output ?? '') };
}
diff --git a/tools/tests/dead-gpu.test.ts b/tools/tests/dead-gpu.test.ts
index 8b00505c0..842a9f7c2 100644
--- a/tools/tests/dead-gpu.test.ts
+++ b/tools/tests/dead-gpu.test.ts
@@ -10,7 +10,7 @@
*/
import { describe, it, expect } from 'vitest';
// @ts-expect-error — a .mjs tool module, typed by its own JSDoc
-import { retryOnDeadGpu, gpuNeverCameUp, deadGpuVerdict, engineCouldNotDraw, resultMeasured,
+import { retryOnDeadGpu, gpuNeverCameUp, deadGpuVerdict, engineCouldNotDraw, resultMeasured, failureLines,
launchNeverHappened, gpuCameUp } from '../lib/deadGpu.mjs';
const DEAD = 'Exiting GPU process due to errors during initialization';
@@ -50,6 +50,21 @@ function runReporting(attempts_: Attempt[]) {
return { ...result, attempts, notes };
}
+describe('failureLines', () => {
+ it('keeps what happened and drops what every launch prints', () => {
+ const out = `${DEAD}\n[6065:ERROR:dbus/bus.cc:405] Failed to connect to the bus\n`
+ + '[screenshot] waitFor timed out: play realm ready\nok frame 3\nelectron exited with signal SIGTRAP';
+ expect(failureLines(out)).toEqual([
+ '[screenshot] waitFor timed out: play realm ready',
+ 'electron exited with signal SIGTRAP',
+ ]);
+ });
+
+ it('says so when an attempt printed no error at all', () => {
+ expect(failureLines(`${DEAD}\nall quiet`)).toEqual(['(the attempt printed no error line)']);
+ });
+});
+
describe('gpuNeverCameUp', () => {
it('recognises the three ways a runner says it has no GPU', () => {
expect(gpuNeverCameUp(DEAD)).toBe(true);
@@ -299,10 +314,16 @@ describe('retryOnDeadGpu', () => {
expect(r.gpuDied).toBeFalsy();
});
- it('gives up at the cap and says the GPU is why', () => {
+ it('gives up at the cap without blaming the GPU on the line every launch prints', () => {
const r = run([DEAD]);
expect(r.ok).toBe(false);
expect(r.attempts).toBe(6);
+ expect(r.gpuDied).toBe(false);
+ });
+
+ it('blames the GPU at the cap when the engine says it could not draw', () => {
+ const r = run([`${DEAD}\n[ERROR] GPU device lost: context-lost [backend=WebGL2]\n[ERROR] Texture::initialize: createTexture failed for 70x70`]);
+ expect(r.attempts).toBe(6);
expect(r.gpuDied).toBe(true);
});
@@ -316,10 +337,10 @@ describe('retryOnDeadGpu', () => {
expect(r.gpuDied).toBeFalsy();
});
- it('still retries a dead GPU, which is not a launch that never happened', () => {
+ it('still retries a run with no verdict, which is not a launch that never happened', () => {
const r = run([DEAD]);
expect(r.launchFailed).toBeFalsy();
- expect(r.gpuDied).toBe(true);
+ expect(r.attempts).toBe(6);
});
});
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index 290871bd3..35744dc34 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -18,11 +18,11 @@
*/
import { spawn, spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
-import { mkdirSync, rmSync, readFileSync, existsSync } from 'node:fs';
+import { mkdirSync, rmSync, readFileSync, existsSync, writeFileSync } from 'node:fs';
import path from 'node:path';
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, launchNeverHappenedVerdict } from './lib/deadGpu.mjs';
+import { retryOnDeadGpu, deadGpuVerdict, launchNeverHappenedVerdict, failureLines } from './lib/deadGpu.mjs';
import { runElectron } from './lib/electronRun.mjs';
import { requireCurrentEngine } from './lib/engineBuild.mjs';
@@ -158,6 +158,16 @@ function designAspect(id) {
return r?.width > 0 && r?.height > 0 ? { w: r.width, h: r.height } : { w: 16, h: 9 };
}
+/**
+ * A failed attempt's whole output, beside the frames: CI uploads that directory when a
+ * run fails, and the lines printed inline are a summary of what only this file holds.
+ */
+function keepAttempt(label, n, output) {
+ try {
+ writeFileSync(path.join(WORK, `${label}-attempt${n}.log`), String(output ?? ''));
+ } catch { /* the log is evidence, not a verdict */ }
+}
+
/**
* The editor's frame of the running game, through the screenshot hook the UI
* shots use. The play panel takes the project's aspect first: a portrait game on
@@ -209,17 +219,20 @@ function captureEditorFrame(id, out, timeoutMs) {
return { ok: false, output: `${output}\nthe capture is not a whole PNG: ${e.message}`, measured: false };
}
};
- const run = retryOnDeadGpu(attempt, (died) => console.log(`↻ ${id} — ${died
- ? 'the GPU process died before the editor drew'
- : 'no editor frame after a GPU death'}; capturing again`));
+ let tries = 0;
+ const run = retryOnDeadGpu(attempt, (noVerdict, last) => {
+ keepAttempt(`${id}-editor`, ++tries, last.output);
+ console.log(`↻ ${id} — ${noVerdict ? 'no editor frame' : 'a blank editor frame after an outage'}; capturing again`);
+ for (const l of failureLines(last.output)) console.log(` ${l}`);
+ });
if (!run.ok) {
return {
ok: false,
why: run.launchFailed
? `${launchNeverHappenedVerdict('the editor\'s frame')} (${run.output.trim().slice(-200)})`
: run.gpuDied
- ? `${deadGpuVerdict('the editor\'s frame')} (${run.output.trim().slice(-200)})`
- : run.output.trim().slice(-300),
+ ? `${deadGpuVerdict('the editor\'s frame')} (${failureLines(run.output).join(' | ')})`
+ : `no frame on any attempt: ${failureLines(run.output).join(' | ')}`,
};
}
return { ok: true, w: run.w, h: run.h };
@@ -288,9 +301,10 @@ function launchPackage(id, target, args) {
r,
};
},
- (died) => console.log(`↻ ${id} ${target} — ${died
- ? 'the GPU process died before it drew'
- : 'a blank frame on the launch after a GPU death'}; launching again`),
+ (noVerdict, last) => {
+ console.log(`↻ ${id} ${target} — ${noVerdict ? 'no verdict from the package' : 'a blank frame after an outage'}; launching again`);
+ for (const l of failureLines(last.output)) console.log(` ${l}`);
+ },
);
// gpuDied travels with the result: without it a runner whose GPU never came up
// is reported as a game that draws nothing, which is the one confusion this