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(verify): a GPU that dies under the walk is retried, not reported as the game

yhhec777ee5b789
diff --git a/tools/run-electron.mjs b/tools/run-electron.mjs
index 64ffc09f6..82db4b6f2 100644
--- a/tools/run-electron.mjs
+++ b/tools/run-electron.mjs
@@ -11,15 +11,27 @@
* node tools/run-electron.mjs <script.mjs> [args…]
*/
import { runElectron } from './lib/electronRun.mjs';
+import { retryOnDeadGpu, deadGpuVerdict } from './lib/deadGpu.mjs';
const args = process.argv.slice(2);
if (!args.length) {
console.error('run-electron: name the script to run under electron');
process.exit(2);
}
-const r = runElectron(args, { stdio: 'inherit' });
-if (r.status === null) {
- console.error(r.stderr?.toString().trim() || 'run-electron: electron did not report a status');
+
+// Captured and relayed rather than inherited, so a dead GPU can be read off the
+// output and the launch retried the way golden's are: hot-update once judged
+// two white frames from an Electron whose GPU process never came up.
+const r = retryOnDeadGpu(() => {
+ const run = runElectron(args, { encoding: 'utf8' });
+ process.stdout.write(run.stdout ?? '');
+ process.stderr.write(run.stderr ?? '');
+ return { ok: run.status === 0, output: `${run.stdout ?? ''}${run.stderr ?? ''}`, status: run.status };
+}, (died) => console.log(`↻ ${args[0]} — ${died
+ ? 'the GPU process never came up' : 'no frame after a GPU death'}; launching again`));
+if (r.gpuDied) console.error(`✗ ${deadGpuVerdict(args[0])}`);
+if (r.status === null || r.status === undefined) {
+ console.error('run-electron: electron did not report a status');
process.exit(1);
}
process.exit(r.status);
diff --git a/tools/verify-playthrough.mjs b/tools/verify-playthrough.mjs
index 36577575f..9f841ae8d 100644
--- a/tools/verify-playthrough.mjs
+++ b/tools/verify-playthrough.mjs
@@ -22,6 +22,7 @@ import { existsSync, mkdirSync, rmSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runElectron } from './lib/electronRun.mjs';
+import { retryOnDeadGpu, deadGpuVerdict, launchNeverHappenedVerdict } from './lib/deadGpu.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const DESKTOP = path.join(ROOT, 'desktop');
@@ -61,20 +62,25 @@ if (exported.status !== 0) {
process.exit(1);
}
-const played = runElectron([
- path.join(ROOT, 'tools', 'launchers', 'play-through.mjs'),
- '--dir', out, '--route', ROUTE,
- '--out', path.join(WORK, `${PROJECT}.png`),
- '--budget', '26000',
-], { encoding: 'utf8', cwd: ROOT });
-
+// A runner whose GPU dies mid-walk loses the WebGL context, and the driver
+// counts that as the game's errors (10/10 legs, errors=4, "unplayable"). Retried
+// like every other launch; the route's own failures still come straight through.
+const played = retryOnDeadGpu(() => {
+ const r = runElectron([
+ path.join(ROOT, 'tools', 'launchers', 'play-through.mjs'),
+ '--dir', out, '--route', ROUTE,
+ '--out', path.join(WORK, `${PROJECT}.png`),
+ '--budget', '26000',
+ ], { encoding: 'utf8', cwd: ROOT });
+ return { ok: r.status === 0, output: `${r.stdout ?? ''}${r.stderr ?? ''}`, stdout: r.stdout, stderr: r.stderr };
+}, (died) => console.log(`↻ ${PROJECT} — ${died
+ ? 'the GPU went away under the walk' : 'no frame after a GPU death'}; walking again`));
for (const line of (played.stdout || '').split('\n')) if (line.trim()) console.log(line);
if (!argv.includes('--keep')) rmSync(WORK, { recursive: true, force: true });
-
-if (played.status !== 0) {
- console.error(`✗ ${PROJECT} cannot be played to the end of its route`);
- // Only stdout was reported, so a driver that never launched left this saying
- // the route failed — which is a verdict about the game, not about the runner.
+if (!played.ok) {
+ console.error(played.launchFailed ? `✗ ${launchNeverHappenedVerdict('the walk')}`
+ : played.gpuDied ? `✗ ${deadGpuVerdict('the route')}`
+ : `✗ ${PROJECT} cannot be played to the end of its route`);
const why = (played.stderr || '').trim();
if (why) console.error(why.slice(-800));
process.exit(1);