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
feat(native): iOS gets the precompiled bytecode Android already had
esengineded9705e4927
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 756b80fb2..74abca857 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,13 @@ published separately; it ships inside the editor.### Added+- **iOS: the first launch after an install is as fast as the rest.** The runtime+ template now carries the SDK's precompiled bytecode on iOS as it already did on+ Android, and the export ships it as a bundle resource — so the host reads the+ compile instead of parsing a ~700 KB bundle on first run. Measured in the+ simulator: **4.5 s → 9 ms**. And when bytecode is declined for any reason, the+ host now says which source it declined and why, rather than silently falling+ back to a parse that only shows up as a slow launch.- **A packaged game carries its own icon.** *Project Settings → Packaging → AppIcon* takes one square PNG (1024×1024 is ideal) and every installable targetuses it: Android as the launcher mipmap, iOS as the asset catalog Xcode derives@@ -88,6 +95,18 @@ published separately; it ships inside the editor.disabled rather than allowed to break a surface. See the[Editor Plugins](https://esengine.github.io/estella/guides/editor-plugins/) guide.+### Fixed++- **The iOS host did not compile.** A `__weak` reference had landed in+ `platform/ios.mm`, which builds under manual reference counting — so every iOS+ build had been failing since. Now `__unsafe_unretained`, which is what a+ non-owning reference means in that file.+- **`cli native --target ios` merged whatever slices it found.** Building the+ device slice and then running in the simulator quietly linked a months-old+ simulator slice, so the app under test was not the engine that had just been+ built. The framework step now names a slice that predates the SDK bundle+ compiled into it.+### Security- **Project platform profiles now require approval.** A `.esengine/platforms/*.mjs`diff --git a/build-tools/utils/iosProject.d.ts b/build-tools/utils/iosProject.d.tsindex 955e3813f..dc1e0319d 100644--- a/build-tools/utils/iosProject.d.ts+++ b/build-tools/utils/iosProject.d.ts@@ -18,6 +18,8 @@ export interface IosProjectSources {infoPlistIn: string;/** The template's default launcher icon, used when the project sets none. */icon: string;+ /** Precompiled SDK bytecode, if the template carries it. */+ bytecode?: string;}export interface IosAppIdentity {diff --git a/build-tools/utils/iosProject.js b/build-tools/utils/iosProject.jsindex 7eafaa2f7..645cfad9d 100644--- a/build-tools/utils/iosProject.js+++ b/build-tools/utils/iosProject.js@@ -14,6 +14,7 @@// CLI and one written by the editor cannot differ.import path from 'path';+import { existsSync } from 'fs';import { cp, mkdir, readdir, rm, readFile, writeFile } from 'fs/promises';import { renderPbxproj, renderScheme } from './xcodeProject.js';import { iosInterfaceOrientations } from './nativeApp.js';@@ -75,6 +76,14 @@ export async function emitIosXcodeProject(contentDir, app, sources, deploymentTaawait writeIconCatalog(contentDir, icon ?? await readFile(sources.icon));+ // The SDK bytecode ships as a bundle resource, where the host's readAsset()+ // finds it — so the first launch after an install is as fast as the rest,+ // exactly as it is on Android. Absent when the template's build machine had no+ // compiler for it; the host then parses and caches, as before.+ if (sources.bytecode && existsSync(sources.bytecode)) {+ await cp(sources.bytecode, path.join(contentDir, path.basename(sources.bytecode)));+ }+const template = await readFile(sources.infoPlistIn, 'utf8');const orientations = iosInterfaceOrientations(app.orientation).map((o) => `\t\t<string>${o}</string>`).join('\n');diff --git a/build-tools/utils/nativeTemplate.d.ts b/build-tools/utils/nativeTemplate.d.tsindex 3e4cf6354..bfda3c982 100644--- a/build-tools/utils/nativeTemplate.d.ts+++ b/build-tools/utils/nativeTemplate.d.ts@@ -41,6 +41,16 @@ export const BYTECODE_FILE: string;export const DEFAULT_ABI: Readonly<Record<NativePlatform, string>>;export function templateId(platform: NativePlatform, abi: string): string;+export interface TemplateEntry {+ /** Path inside the template. */+ rel: string;+ kind?: 'dir';+ optional?: boolean;+ /** Produced by the emitter rather than copied (the Java shim's dex). */+ produced?: boolean;+}++export function templateLayout(platform: NativePlatform, options?: { abi?: string }): TemplateEntry[];export function requiredTemplateFiles(platform: NativePlatform, options?: { abi?: string }): string[];export function missingTemplateFiles(dir: string, platform: NativePlatform, options?: { abi?: string }): string[];export function readTemplateManifest(dir: string): NativeTemplateManifest | null;@@ -71,4 +81,7 @@ export function iosTemplateSources(dir: string): {infoPlistIn: string;/** The default launcher icon, used when the project sets none. */icon: string;+ /** Precompiled SDK bytecode, when the template's build machine could produce+ * it — the difference between a fast first launch and a parse. */+ bytecode: string;};diff --git a/build-tools/utils/nativeTemplate.js b/build-tools/utils/nativeTemplate.jsindex 4b9d0645d..d4a4e5dd0 100644--- a/build-tools/utils/nativeTemplate.js+++ b/build-tools/utils/nativeTemplate.js@@ -69,6 +69,14 @@ export function templateLayout(platform, options = {}) {{ rel: 'App/main.m', from: (ctx) => path.join(ctx.root, 'native', 'ios', 'App', 'main.m') },{ rel: 'App/Info.plist.in', from: (ctx) => path.join(ctx.root, 'native', 'ios', 'App', 'Info.plist.in') },{ rel: DEFAULT_ICON, from: (ctx) => path.join(ctx.root, 'native', 'icon.png') },+ // The same first-launch fix the Android template carries: without it the+ // host parses the ~700 KB SDK bundle on first run, which is seconds of+ // black screen after an install. Absent is valid — the host compiles and+ // caches instead.+ {+ rel: `assets/${BYTECODE_FILE}`, optional: true,+ from: (ctx) => path.join(ctx.root, 'build-native-ios', 'gen', BYTECODE_FILE),+ },];}if (platform === 'android') {@@ -255,5 +263,6 @@ export function iosTemplateSources(dir) {mainM: path.join(dir, 'App', 'main.m'),infoPlistIn: path.join(dir, 'App', 'Info.plist.in'),icon: path.join(dir, DEFAULT_ICON),+ bytecode: path.join(dir, 'assets', BYTECODE_FILE),};}diff --git a/desktop/electron/nativeTemplates.ts b/desktop/electron/nativeTemplates.tsindex 6f1ed9000..df2023d87 100644--- a/desktop/electron/nativeTemplates.ts+++ b/desktop/electron/nativeTemplates.ts@@ -50,7 +50,7 @@ export function resolveNativeTemplate(platform: NativePlatform, engineVersion: s/** The three files an iOS Xcode project is built around, or null without a template. */export function iosSourcesFromTemplate(engineVersion: string): {- xcframework: string; mainM: string; infoPlistIn: string; icon: string;+ xcframework: string; mainM: string; infoPlistIn: string; icon: string; bytecode: string;} | null {const template = resolveNativeTemplate('ios', engineVersion);return template ? iosTemplateSources(template.dir) : null;diff --git a/desktop/tests/native-template.test.ts b/desktop/tests/native-template.test.tsindex 21f644033..c5f622676 100644--- a/desktop/tests/native-template.test.ts+++ b/desktop/tests/native-template.test.ts@@ -20,7 +20,7 @@ import {} from '../electron/nativeTemplates';import { listPlatforms } from '../electron/platformCatalog';import {- requiredTemplateFiles, installedTemplateDir, parseTemplateIndex,+ requiredTemplateFiles, templateLayout, installedTemplateDir, parseTemplateIndex,TEMPLATE_FORMAT, TEMPLATE_MANIFEST, TEMPLATE_INDEX,} from '../../build-tools/utils/nativeTemplate.js';import { makeZip } from '../../build-tools/utils/zip.js';@@ -278,10 +278,14 @@ describe('the template layout is the one source of filenames', () => {expect(sources.xcframework).toBe(path.join(dir, 'Estella.xcframework'));expect(sources.mainM).toBe(path.join(dir, 'App', 'main.m'));expect(sources.infoPlistIn).toBe(path.join(dir, 'App', 'Info.plist.in'));- // And each is something the emitter is required to have written.- const required = requiredTemplateFiles('ios');+ // And every one of them is a file the layout declares — including the+ // bytecode, which is optional (a build machine without a host compiler ships a+ // template without it, and the app compiles on first launch instead).+ const declared = templateLayout('ios').map((e) => e.rel);for (const file of Object.values(sources)) {- expect(required).toContain(path.relative(dir, file).split(path.sep).join('/'));+ expect(declared).toContain(path.relative(dir, file).split(path.sep).join('/'));}+ expect(requiredTemplateFiles('ios')).not.toContain(+ path.relative(dir, sources.bytecode).split(path.sep).join('/'));});});diff --git a/native/host/Runtime.cpp b/native/host/Runtime.cppindex 4e9754acc..8dead325c 100644--- a/native/host/Runtime.cpp+++ b/native/host/Runtime.cpp@@ -208,14 +208,29 @@ uint64_t hashBytes(const char* p, size_t n) {*/bool tryBytecode(HostState& h, const u8* blob, size_t size, uint64_t want,const char* origin, JSValue& out) {- if (size <= sizeof(uint64_t)) return false;+ // Every rejection says why. Falling back to a parse is CORRECT but costs+ // seconds of black screen on first launch, so a build that shipped bytecode+ // the host then declined has to be able to say so — silence here is how such a+ // build passes for a working one.+ if (size <= sizeof(uint64_t)) {+ ESHOST_LOGI("SDK bundle: ignoring %s — %zu bytes is not a [hash][bytecode] blob", origin, size);+ return false;+ }uint64_t got = 0;std::memcpy(&got, blob, sizeof(got));- if (got != want) return false; // built against a different bundle+ if (got != want) {+ ESHOST_LOGI("SDK bundle: ignoring %s — built against a different bundle "+ "(%016llx, want %016llx)", origin,+ (unsigned long long)got, (unsigned long long)want);+ return false;+ }JSValue fn = JS_ReadObject(h.js, blob + sizeof(got), size - sizeof(got), JS_READ_OBJ_BYTECODE);if (JS_IsException(fn)) {JSValue e = JS_GetException(h.js);+ const char* msg = JS_ToCString(h.js, e);+ ESHOST_LOGE("SDK bundle: %s did not load (%s) — falling back to a parse", origin, msg ? msg : "?");+ if (msg) JS_FreeCString(h.js, msg);JS_FreeValue(h.js, e);return false;}