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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
test(render): losing the GPU is a scene, judged by what it draws afterwards
esengine1bb342e1e93b
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjsindex d0f57f1d2..30942485d 100644--- a/desktop/scripts/headless-verify.mjs+++ b/desktop/scripts/headless-verify.mjs@@ -137,7 +137,7 @@ app.whenReady().then(async () => {webPreferences: { offscreen: false },});onRendererConsole(win.webContents, (msg) => {- if (/error|fail|unwind|exception|webgl/i.test(msg)) console.log('[renderer]', msg.slice(0, 240));+ if (/error|fail|unwind|exception|webgl|recovery|placeholder/i.test(msg)) console.log('[renderer]', msg.slice(0, 240));});await win.loadURL(url);@@ -247,6 +247,7 @@ app.whenReady().then(async () => {out.guard = d.guard();out.tablesAtLoss = d.glTables();+ out.awaitingAtLoss = d.awaiting();out.glLostBeforeRestore = d.contextLost();out.restoreCalled = d.restore();await new Promise((r) => setTimeout(r, 500));@@ -259,12 +260,14 @@ app.whenReady().then(async () => {if (!out.recovered) await new Promise((r) => setTimeout(r, 100));}out.statusAfterRecover = d.status();+ out.awaitingAfterRecover = d.awaiting();// The full cycle: rebuild, re-upload the textures, and declare it whole.out.fullRecovered = await d.recoverFull();out.statusAfterFull = d.status();out.tablesAfterFull = d.glTables();- api.step(${STEPS}, 1 / 60);+ out.awaitingAfterFull = d.awaiting();+ await api.step(${STEPS}, 1 / 60);out.drawCallsAfterRecover = api.getStats ? api.getStats().drawCalls : -1;return out;})()`);diff --git a/desktop/src/headless.ts b/desktop/src/headless.tsindex 2f8ee3f92..275547b53 100644--- a/desktop/src/headless.ts+++ b/desktop/src/headless.ts@@ -33,6 +33,8 @@ declare global {recover(): boolean;finishRecovery(): void;recoverFull(): Promise<boolean>;+ /** The engine's own list of textures still on the placeholder. */+ awaiting(): string[];glTables(): Record<string, number>;lose(): boolean;contextLost(): boolean | null;@@ -90,6 +92,10 @@ window.__estellaHeadless = {if (!assets) return false;return assets.recoverFromDeviceLoss();},+ // The engine's list, not a count: which textures did not come back is the+ // answer a failing recovery needs, and a number cannot give it.+ awaiting: () => (EngineHost.getResource(Assets)?.texturesAwaitingReupload() ?? [])+ .map((t) => `${t.handle}|${t.path}`),// EXPERIMENT: emscripten's GL object tables are the suspected blocker —// they hold wrappers minted against the dead context. Counting them says// whether a rebuild refilled them or merely added to the stale ones.diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex f0e9d1d5f..eab077939 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -112,6 +112,14 @@ export const SCENES = [{ id: "material-preview", tier: "pr", webgpu: { ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" }, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-tint.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-tint.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PREVIEW: "{\"w\":64,\"h\":64,\"rgb\":[255,0,0],\"tol\":45}" } },{ id: "tilemap-hex", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/tilemap-hex.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/tilemap-hex.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "6", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.40,\"y\":0.40,\"rgb\":[255,0,0]},{\"x\":0.60,\"y\":0.40,\"rgb\":[0,255,0]},{\"x\":0.50,\"y\":0.55,\"rgb\":[0,0,255]},{\"x\":0.70,\"y\":0.55,\"rgb\":[255,255,0]}]" } },{ id: "postprocess-lut", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_SCENE: "/scenes/lut-grade.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/lut-grade.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "10", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.292,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":40},{\"x\":0.708,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },+ // Takes the GPU away for real (WEBGL_lose_context) and drives the whole+ // recovery. It reuses tilemap-flip because the capture happens AFTER the+ // cycle, and those four points are SAMPLED FROM ITS ATLAS — so they fail+ // unless the asset layer put the content back, which is the half of recovery+ // no backend can do for itself. A scene whose colours come from vertices+ // passes with the re-upload deleted; this one was chosen by breaking it.+ // No `webgpu` — a WebGPU device cannot be taken away through a GL extension.+ { id: "device-loss", tier: "pr", env: { ESTELLA_VERIFY_DEVICE_LOSS: "1", ESTELLA_VERIFY_SCENE: "/scenes/tilemap-flip.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/tilemap-flip.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.40,\"y\":0.36,\"rgb\":[255,0,0]},{\"x\":0.60,\"y\":0.36,\"rgb\":[0,255,0]},{\"x\":0.40,\"y\":0.58,\"rgb\":[0,0,255]},{\"x\":0.60,\"y\":0.58,\"rgb\":[255,255,0]}]" } },];const rank = (tier) => TIERS.indexOf(tier);