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
fix(export): a Meta playable is judged against the 5MB Meta publishes
esengine8f115119c8f4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6e42eb2f8..c4e1dac50 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -42,6 +42,14 @@ published separately; it ships inside the editor.### Fixed+- **A Meta playable can spend all 5MB Meta allows.** The export refused one over 2MB and+ quoted that figure as Meta's cap. It is not: Meta's specification says "Maximum file size:+ 5MB" for a playable HTML5 file, and 5MB again for a whole ZIP of at most 100 files. The+ 2MB is folklore, repeated across the web and published nowhere, and every Meta playable+ was built against half the budget it had. The unnamed-network default moves to 5MB with+ it, that being what every network cited here accepts, and each network's enforced cap is+ now held to the sentence quoted beside it — the two had drifted apart in silence.+- **A sprite with no texture is no longer reported as unfinished.** The editor called`Sprite.texture` a required field, so every coloured quad — a health bar, a panel, aplaceholder — raised a finding in the Details panel, the diagnostics sweep and the builddiff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.tsindex bddf24d4e..2e0fea236 100644--- a/pipeline/src/export/exportPlayable.ts+++ b/pipeline/src/export/exportPlayable.ts@@ -10,7 +10,7 @@* (keyed by the scene's @uuid: refs — EmbeddedAssetProvider resolves them);* - the playable host + esengine + project scripts esbuilt to ONE IIFE,* deflated like the engine's own payloads and started by a small loader- * script — it is the page's largest span, and a 2MB cap is spent on it;+ * script — it is the page's largest span, and a 5MB cap is spent on it;* - whatever the chosen ad network's profile injects (playableAdProfile.ts).* Boots the SAME shipping runtime via initPlayableRuntime (play == ship).*@@ -204,7 +204,7 @@ export async function exportPlayable(opts: {/*** Defaults to ON here, unlike every other target: a playable is uploaded* under a hard byte cap and has no dev build, and unminified spent 0.31MB of- * a 2MB budget on whitespace. A no-op on what it draws (measured: identical+ * a 5MB budget on whitespace. A no-op on what it draws (measured: identical* to the pixel). An explicit `false` is still honoured.*/minify?: boolean;diff --git a/pipeline/src/export/playableAdProfile.ts b/pipeline/src/export/playableAdProfile.tsindex 3450b69e0..5ef4e66aa 100644--- a/pipeline/src/export/playableAdProfile.ts+++ b/pipeline/src/export/playableAdProfile.ts@@ -65,22 +65,22 @@ export interface PlayableAdProfile {export const genericPlayableProfile: PlayableAdProfile = {id: 'generic',label: 'Generic (single-file HTML5)',- maxBytes: 2 * 1024 * 1024,- limitNote: "no network selected — using Meta's 2MB index.html cap, the strictest we know of",+ maxBytes: 5 * 1024 * 1024,+ limitNote: 'no network selected — 5MB, which is what every network we cite accepts',};/**- * Meta (Facebook / Instagram) playable ads, single-file format. Meta caps the- * index.html itself at 2MB (its 5MB figure is the total for a ZIP bundle, which a- * single-file playable has no way to spend), forbids any HTTP request — hence- * nothing in `<head>` — and requires the click-through to call its own function.+ * Meta (Facebook / Instagram) playable ads, single-file format. Meta forbids any+ * HTTP request — hence nothing in `<head>` — and requires the click-through to+ * call its own function. 5MB is Meta's own "Maximum file size: 5MB" for a playable+ * HTML5 file; the widely repeated 2MB appears nowhere in the spec.* @see https://www.facebook.com/business/help/412951382532338*/export const metaPlayableProfile: PlayableAdProfile = {id: 'meta',label: 'Meta (Facebook / Instagram)',- maxBytes: 2 * 1024 * 1024,- limitNote: "Meta caps a playable's index.html at 2MB",+ maxBytes: 5 * 1024 * 1024,+ limitNote: 'Meta caps a playable HTML5 file at 5MB',emitBridge: () => 'window.__ESTELLA_PLAYABLE__={cta:function(){'+ 'if(typeof FbPlayableAd!=="undefined"&&FbPlayableAd.onCTAClick)FbPlayableAd.onCTAClick();'+ '}};',diff --git a/pipeline/src/runtime/playableLoader.ts b/pipeline/src/runtime/playableLoader.tsindex d087dbf99..a07b8ed81 100644--- a/pipeline/src/runtime/playableLoader.ts+++ b/pipeline/src/runtime/playableLoader.ts@@ -4,7 +4,7 @@* @file playableLoader.ts — inflate the game bundle, then run it.** The engine's glue and its wasm travel deflated; the game's own bundle is the- * largest span in the page and travelled as source, which on a 2MB cap is the+ * largest span in the page and travelled as source, which on a 5MB cap is the* difference between fitting and not. It arrives as `__GAME_BUNDLE__` and runs* from the same blob script the engine module already needs, so a page that can* boot a playable at all can boot this one — no eval, nothing new to allow.diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.tsindex a977e8a8c..31c15d5b6 100644--- a/pipeline/tests/export-playable.test.ts+++ b/pipeline/tests/export-playable.test.ts@@ -9,6 +9,7 @@*/import { describe, it, expect, beforeAll, afterAll } from 'vitest';import { runtimeConfigOf } from '../src/project/runtimeConfig';+import { BUILTIN_PLAYABLE_PROFILES } from '../src/export/playableAdProfile';import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import path from 'node:path';@@ -122,7 +123,7 @@ describe('exportGame (playable)', () => {expect(inlinedText(html, '__GAME_BUNDLE__')).toContain('createObjectURL'); // real host bundledexpect(inlinedText(html, '__GAME_BUNDLE__')).toContain('SpawnMarker'); // project script bundled// And it travels deflated. Inlining the source again would satisfy every- // assertion above — this is the one that would notice, and the 2MB cap is+ // assertion above — this is the one that would notice, and the 5MB cap is// spent on this span more than on any other.const game = inlinedText(html, '__GAME_BUNDLE__');expect(html).not.toContain(game.slice(0, 200));@@ -168,7 +169,7 @@ describe('exportGame (playable)', () => {// No dev build of a playable exists, so this target minifies unless told not// to — the opposite default from every other. Unminified spent 0.31MB of a- // 2MB budget on whitespace.+ // 5MB budget on whitespace.it('minifies by default, and still honours an explicit no', async () => {const run = async (minify: boolean | undefined, dir: string): Promise<number> => {const res = await exportGame({@@ -278,7 +279,7 @@ describe('exportGame (playable)', () => {// reported no limit at all would be the one that surprises you at upload.const verdict = res.size?.verdicts.find((v) => v.budget.scope === 'deliverable');expect(verdict?.status).toBe('ok');- expect(verdict?.budget.maxBytes).toBe(2 * 1024 * 1024);+ expect(verdict?.budget.maxBytes).toBe(5 * 1024 * 1024);}, 60_000);it('inlines the project camera fit as __GAME_SCREENFIT__ (only when opted in)', async () => {@@ -487,3 +488,17 @@ export function packagedRuntimeInit(c){return c;}\n`);}}, 60_000);});++describe('playable ad profiles', () => {+ // The cap enforced and the sentence quoted to the developer are two copies of+ // one fact, and only the sentence is checkable against the network's docs.+ // Meta's note said 5MB while it refused at 2MB, and no test read the number.+ it('every built-in network enforces the number its note quotes', () => {+ for (const p of BUILTIN_PLAYABLE_PROFILES) {+ const quoted = /(\d+(?:\.\d+)?)\s*MB/i.exec(p.limitNote);+ expect(quoted, `${p.id}: limitNote must quote the cap it enforces — "${p.limitNote}"`).not.toBeNull();+ expect(p.maxBytes, `${p.id} enforces ${p.maxBytes}B, its note says ${quoted?.[1]}MB`)+ .toBe(Number(quoted?.[1]) * 1024 * 1024);+ }+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex e88caf34e..c938761a5 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -37,6 +37,9 @@ export const NOTED = {'fix(gates): a gate that needs a required field asks which one is still required':{ note: 'A sprite with no texture is no longer reported as unfinished.' },+ 'fix(export): a Meta playable is judged against the 5MB Meta publishes':+ { note: 'A Meta playable can spend all 5MB Meta allows.' },+'feat(render): the WebGPU backend draws the scene and the backbuffer multisampled':{ note: 'Geometry edges are anti-aliased on WebGPU, which is every native build.' },