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.

feat(gates): a mini-game package is asked what it does when a 分包 is refused

esengine8f10b027b38d
diff --git a/examples/input-actions/project.esproject b/examples/input-actions/project.esproject
index 32b380d26..9ad100606 100644
--- a/examples/input-actions/project.esproject
+++ b/examples/input-actions/project.esproject
@@ -9,5 +9,8 @@
"width": 800,
"height": 600
},
- "spineVersion": "none"
+ "spineVersion": "none",
+ "packaging": {
+ "engineSubpackage": true
+ }
}
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index 12d4cc791..a473d580b 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -116,8 +116,7 @@ export const SHIPPED = {
{ notCertifiable: 'a byte count no frame shows — a package that dropped a subsystem its'
+ ' content uses fails the wechat pairs\' pixel parity, which is where it is caught' },
'The engine can ship outside a WeChat mini-game\'s main package entirely.':
- { notCertifiable: 'where a file sits in the package, not what it draws; no tier builds a'
- + ' project with the engine in a 分包 — it boots in the stand-in host by hand' },
+ { certifies: 'subpackage' },
'A WeChat mini-game can ship its engine compressed, freeing a third of the main package.':
{ notCertifiable: 'as above — bytes, not pixels; the compressed package boots in the'
+ ' stand-in host and export-wechat holds the naming both halves agree on' },
@@ -548,6 +547,10 @@ export const EVIDENCE = {
// A package's, not a source's: the claim is that a second vendor's package
// boots, which only the launched package can show.
'minigame-vendor': null,
+ // Where the engine binary SITS in the package, which no source mentions: the
+ // `subpackage` block on input-actions is the claim, and the pair of launches
+ // it drives (mounted, then refused) is what backs it.
+ subpackage: null,
'sprite-draw-mode': /\bdrawMode\b/,
'hot-update': /\b(checkForUpdate|applyUpdate)\b/,
rollback: /\b(applyUpdate|rollback)\b/,
@@ -577,7 +580,6 @@ export const KNOWN_GAPS = {
// What no automated run reaches is the vendor mounting it: only a mini-game
// host implements the download, and none of the tiers builds for one.
'authored-sound': 'AudioSource.playing is what a graph, a behaviour or a wire raises, and audio-demo still starts its loop from code through Res(Audio) — no golden project sounds a clip from authored data yet; audio-source-flag.test.ts holds the contract',
- subpackage: 'hot-update-demo delivers `pack` as a 分包 and its button loads it, but no tier builds that project for a mini-game host — the vendor download itself is verified by hand in devtools',
};
/**
@@ -880,13 +882,17 @@ export const GOLDEN = [
},
{
id: 'input-actions',
- certifies: ['input', 'minigame-vendor'],
+ certifies: ['input', 'minigame-vendor', 'subpackage'],
// Two vendors from one project: the export is a profile over one family, and
// only a second vendor's real boot shows what the family got wrong. They take
// the same engine build, so the second costs no extra wasm build.
targets: ['web', 'desktop', 'wechat', 'douyin'],
tier: 'release',
interact: { keys: ['KeyD'], frames: 40 },
+ // Its engine binary rides a 分包 — the only way under the 4MB main-package
+ // limit. Naming it here lets the host REFUSE it too: on a bad network the
+ // game cannot start, and all it can still do is say which package failed.
+ subpackage: { name: 'engine' },
},
{
id: 'sprite-animation',
@@ -999,6 +1005,11 @@ export function audioFor(g) {
return g.audio ?? null;
}
+/** The 分包 a mini-game package rides, or null. See input-actions. */
+export function subpackageFor(g) {
+ return g.subpackage ?? null;
+}
+
export function interactFor(g) {
if (g.interactGap || !g.interact) return null;
return {
diff --git a/tools/launchers/launch-minigame.mjs b/tools/launchers/launch-minigame.mjs
index a7475a819..85e5d93df 100644
--- a/tools/launchers/launch-minigame.mjs
+++ b/tools/launchers/launch-minigame.mjs
@@ -54,7 +54,13 @@ const H = Number(flag('h', '360'));
const SETTLE = Number(flag('settle', '30'));
const TIMEOUT = Number(flag('timeout', '30000'));
const INPUT = flag('input', '');
-/** Make the host refuse this 分包, to see what the package does about it. */
+/**
+ * Make the host refuse this 分包 — and with it, ask a different question.
+ *
+ * The package is not supposed to start. A 分包 that will not come down is a
+ * failure a shipped game meets on a bad network, and all it can still do is SAY
+ * so, which is what the verdict flips to: silence is the failure here.
+ */
const FAIL_SUBPACKAGE = flag('fail-subpackage', '');
const MIME = {
@@ -169,10 +175,16 @@ async function main() {
server.close();
const live = frameIsLive(image);
- const ok = painted && live && errors.length === 0;
- console.log(`${ok ? '✓' : '✗'} ${path.basename(DIR)} (mini-game) — painted=${painted} live=${live} errors=${errors.length}`);
+ const said = errors.find((e) => e.includes(`subpackage ${FAIL_SUBPACKAGE} did not load`));
+ const ok = FAIL_SUBPACKAGE
+ ? said !== undefined
+ : painted && live && errors.length === 0;
+ console.log(`${ok ? '✓' : '✗'} ${path.basename(DIR)} (mini-game) — `
+ + (FAIL_SUBPACKAGE
+ ? `${FAIL_SUBPACKAGE} refused: the package ${said ? 'said why' : 'said nothing'}`
+ : `painted=${painted} live=${live} errors=${errors.length}`));
for (const e of errors.slice(0, 5)) console.log(` ${e}`);
- if (painted && !live) console.log(' one flat colour — it started and drew nothing');
+ if (!FAIL_SUBPACKAGE && painted && !live) console.log(' one flat colour — it started and drew nothing');
if (!ok) {
// What the boot last announced through the host indicator. A package stuck
// fetching its engine 分包 and one stuck on its first scene look identical
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index 9019ba31e..84b6e7fd4 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -25,7 +25,7 @@ import { spawn, spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { mkdirSync, rmSync, readFileSync, existsSync, writeFileSync } from 'node:fs';
import path from 'node:path';
-import { atTier, sharesOf, projectDir, parityFor, interactFor, audioFor, suspendFor, safeAreaFor, atlasFor, webPixels, launchTimeoutFor, ROOT } from './goldenProjects.mjs';
+import { atTier, sharesOf, projectDir, parityFor, interactFor, audioFor, suspendFor, safeAreaFor, atlasFor, subpackageFor, webPixels, launchTimeoutFor, ROOT } from './goldenProjects.mjs';
import { frameDistance, frameCellMax, readPNG } from './frameCompare.mjs';
import { retryOnDeadGpu, deadGpuVerdict, launchNeverHappenedVerdict, failureLines } from './lib/deadGpu.mjs';
import { runElectron, ensureElectronBinary } from './lib/electronRun.mjs';
@@ -438,6 +438,26 @@ for (const { id, target } of pairs) {
console.log(`${ok ? '✓' : '✗'} ${id} ${target} — audio: ${audio.bar} at ${height ?? 'nothing'} (silent floor ${audio.floor})`);
}
+ // The 分包 the host REFUSES. The ordinary launch above already proved the happy
+ // half (this package's engine rides a 分包, so it booted through one); what has
+ // never run is the half a player on a bad network gets.
+ const subpackage = MINIGAME.has(target) ? subpackageFor(golden) : null;
+ if (subpackage) {
+ const refused = launchPackage(id, target, [
+ '--dir', out,
+ ...(timeoutMs ? ['--timeout', String(timeoutMs)] : []),
+ '--fail-subpackage', subpackage.name,
+ ]);
+ const ok = refused.status === 0;
+ results.push({
+ id, target, stage: 'subpackage-refused', ok,
+ why: ok ? '' : `the package said nothing when ${subpackage.name} was refused`
+ + ' — a black frame is all a player would get',
+ });
+ console.log(`${ok ? '✓' : '✗'} ${id} ${target} — ${subpackage.name} refused:`
+ + ` the package ${ok ? 'said why' : 'said nothing'}`);
+ }
+
const tolerance = COMPARABLE.has(target) && !NO_PARITY ? parityFor(golden) : null;
const editorPng = path.join(WORK, `${id}-editor.png`);
// ...times SHARE, as launchPackage already does for the other side: both frames