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(debug): a connected build says which graphics API it draws through
esenginec271ace9f47d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9128a9210..1407a04e6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -18,6 +18,7 @@ published separately; it ships inside the editor.- **Android release signing.** A Shipping APK (and App Bundle) is signed with the release key the project names under Project Settings → Android → Signing — two PEM paths, the passphrase kept in this machine's keychain (the command line reads `ESTELLA_ANDROID_KEY_PASSPHRASE`); Development builds keep the development key. A Shipping build without one says it will be refused by Google Play.- **EmscriptenGLX on WeChat.** A WeChat project can ship the engine linked with WeChat's EmscriptenGLX (Project Settings → WeChat → Render through EmscriptenGLX, off by default), which issues the engine's GL calls natively instead of through JavaScript: a draw-heavy scene spent about 12% less time rendering on an Android phone. It adds about 310KB of wasm and needs base library 3.8.12 on Android, or iOS in 高性能+ mode; any other host renders through WebGL2 as before, and the log says which. The engine is built once with `node build-tools/cli.js build -t wechat-glx`, which fetches WeChat's library at a pinned version and hash, and emsdk 4.0.10 beside the main one; an export that asks for it without it says so.+- A connected development build says which graphics API it draws through — WebGL2, EmscriptenGLX or WebGPU — once its game has started: the Profiler shows it beside the device's controls, the Output Log notes it, and `device_targets` returns it as `graphics`. A WeChat build set to EmscriptenGLX reports WebGL2 on a host that does not offer it.- **Export profiles.** A project can name several exports of one target in `packaging.profiles` — a test and a production WeChat build, each with its own AppID, CDN root and development or shipping configuration, writing only what differs from the project's settings. The Build dialog creates, edits and deletes them per target, marking each setting a profile overrides with a reset that hands it back to the project; `estella export --profile <name>` and the agent's `export_game` build the same one, and the size history records which profile a build used.### Changeddiff --git a/desktop b/desktopindex 2ffa46e9f..547804c8b 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 2ffa46e9f332d346a2075e501e4c4c30944d76f1+Subproject commit 547804c8bde01f20d252edcb65e6b8be8b714543diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 30ea95ff6..4c89d6470 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -2726,7 +2726,11 @@ url: string## DebugChannelMessage — type @experimental```-| { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+| {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> }@@ -6619,7 +6623,13 @@ triangles: number## RenderSurfaceSource — type @experimental```-| { readonly kind: 'gl-context'; readonly handle: number }+| {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 2fa298f09..ad1941327 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -2734,7 +2734,11 @@ url: string## DebugChannelMessage — type @experimental```-| { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+| {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> }@@ -6820,7 +6824,13 @@ triangles: number## RenderSurfaceSource — type @experimental```-| { readonly kind: 'gl-context'; readonly handle: number }+| {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 633550f82..e2295f315 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -2721,7 +2721,11 @@ url: string## DebugChannelMessage — type @experimental```-| { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+| {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> }@@ -6614,7 +6618,13 @@ triangles: number## RenderSurfaceSource — type @experimental```-| { readonly kind: 'gl-context'; readonly handle: number }+| {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 6bfde910d..4f0cac303 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -2721,7 +2721,11 @@ url: string## DebugChannelMessage — type @experimental```-| { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+| {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> }@@ -6884,7 +6888,13 @@ triangles: number## RenderSurfaceSource — type @experimental```-| { readonly kind: 'gl-context'; readonly handle: number }+| {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 38382dcc1..e7987463f 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -2721,7 +2721,11 @@ url: string## DebugChannelMessage — type @experimental```-| { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+| {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> }@@ -6621,7 +6625,13 @@ triangles: number## RenderSurfaceSource — type @experimental```-| { readonly kind: 'gl-context'; readonly handle: number }+| {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;diff --git a/sdk/src/app/app.ts b/sdk/src/app/app.tsindex c5f54cf42..2c918ecd3 100644--- a/sdk/src/app/app.ts+++ b/sdk/src/app/app.ts@@ -1614,7 +1614,13 @@ export class App {* and must not reach the '#canvas' fallback.*/export type RenderSurfaceSource =- | { readonly kind: 'gl-context'; readonly handle: number }+ | {+ readonly kind: 'gl-context';+ readonly handle: number;+ /** The context is WeChat's EmscriptenGLX one, whose GL calls the linked+ * library issues natively rather than through the JS glue. */+ readonly glx?: boolean;+ }| {readonly kind: 'webgpu';readonly canvasSelector?: string;@@ -1686,6 +1692,23 @@ export interface WebAppOptions {screenFit?: ScreenScalingData;}+/** The graphics API a web app's renderer draws through, as a connected device reports it. */+export type GraphicsPath = 'WebGPU' | 'WebGL2' | 'EmscriptenGLX';+const graphicsPaths = new WeakMap<App, GraphicsPath>();++/** Null for an app whose module resolved its own surface. */+export function graphicsPathOf(app: App): GraphicsPath | null {+ return graphicsPaths.get(app) ?? null;+}++export function graphicsPathFor(surface: RenderSurfaceSource): GraphicsPath | null {+ switch (surface.kind) {+ case 'webgpu': return 'WebGPU';+ case 'gl-context': return surface.glx ? 'EmscriptenGLX' : 'WebGL2';+ case 'default': return null;+ }+}+export function createWebApp(module: ESEngineModule, options?: WebAppOptions): App {// Restore any engine components a prior project hot-reload's clearUserComponents// wiped, so the scene about to load can still resolve them (no-op before the SDK@@ -1729,6 +1752,8 @@ export function createWebApp(module: ESEngineModule, options?: WebAppOptions): Amodule.initRenderer();break;}+ const graphics = graphicsPathFor(surface);+ if (graphics) graphicsPaths.set(app, graphics);// Always applied (not only when set): the renderer outlives the App on realm// reloads, so a fresh App must reset a prior session's y-sort state too.module.renderer_setYSortLayers?.((options?.ySortLayers ?? 0) >>> 0);diff --git a/sdk/src/runtime/debugChannel.ts b/sdk/src/runtime/debugChannel.tsindex d51d706e1..3067695e8 100644--- a/sdk/src/runtime/debugChannel.ts+++ b/sdk/src/runtime/debugChannel.ts@@ -11,7 +11,7 @@* mini-game host cannot be reached, and the editor authenticates the dial by the* token in its URL before a single frame crosses.*/-import type { App } from '../app/app';+import { graphicsPathOf, type App } from '../app/app';import { getPlatform, platformNow } from '../platform/base';import type { PlatformSocket } from '../platform/types';import type { NextFrame } from '../render/frameCapture';@@ -131,6 +131,7 @@ export function startDebugChannel(config: DebugChannelConfig): void {send({t: 'hello', v: DEBUG_CHANNEL_PROTOCOL, platform: platform.name, title: platform.deviceName?.() ?? '',project: config.project ?? null, revision: assets?.getManifest()?.revision() ?? null,+ graphics: app ? graphicsPathOf(app) : null,});};diff --git a/sdk/src/runtime/debugChannelProtocol.ts b/sdk/src/runtime/debugChannelProtocol.tsindex 4d49a40bd..c49e2e84f 100644--- a/sdk/src/runtime/debugChannelProtocol.ts+++ b/sdk/src/runtime/debugChannelProtocol.ts@@ -42,7 +42,11 @@ export type DebugChannelQuery =* host that traces its own every call prints thousands a second.*/export type DebugChannelMessage =- | { t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null }+ | {+ t: 'hello'; v: number; platform: string; title: string; project: string | null; revision: string | null;+ /** The graphics API the game draws through; null until the game has started. */+ graphics: string | null;+ }| { t: 'reply'; reqId: number; data: unknown; pixels?: number }| { t: 'reply'; reqId: number; error: string }| { t: 'logs'; entries: Array<{ level: ConsoleLevel; line: string }> };diff --git a/sdk/src/runtime/miniGameRuntime.ts b/sdk/src/runtime/miniGameRuntime.tsindex c7b5c0236..ca74cb1d5 100644--- a/sdk/src/runtime/miniGameRuntime.ts+++ b/sdk/src/runtime/miniGameRuntime.ts@@ -288,7 +288,7 @@ export async function initMiniGameRuntime(config: MiniGameRuntimeConfig): Promisif (glx) (module as unknown as GlxModule).ccall('glxUpdateContextId', 'number', ['number'], [glx.ctxid]);const app = createWebApp(module, {- renderSurface: { kind: 'gl-context', handle: glHandle },+ renderSurface: { kind: 'gl-context', handle: glHandle, glx: glx !== undefined },ySortLayers: config.ySortLayers,depthLayers: config.depthLayers,colorSpace: config.colorSpace,diff --git a/sdk/tests/debug-channel-graphics.test.ts b/sdk/tests/debug-channel-graphics.test.tsnew file mode 100644index 000000000..88ea0faa3--- /dev/null+++ b/sdk/tests/debug-channel-graphics.test.ts@@ -0,0 +1,45 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file A connected build says which graphics API it draws through, once its+ * game has started — a WeChat build set to EmscriptenGLX falls back to+ * WebGL2 on most hosts, and only the device knows which it got.+ */+import { describe, it, expect, vi } from 'vitest';+import { setPlatform } from '../src/platform/base';+import type { PlatformAdapter, PlatformSocket } from '../src/platform/types';+import { graphicsPathFor, type App } from '../src/app/app';++vi.mock('../src/app/app', async (actual) => ({+ ...await actual<typeof import('../src/app/app')>(),+ graphicsPathOf: () => 'EmscriptenGLX',+}));++describe('the graphics path a device reports', () => {+ it('follows the surface the engine was given', () => {+ expect(graphicsPathFor({ kind: 'gl-context', handle: 1 })).toBe('WebGL2');+ expect(graphicsPathFor({ kind: 'gl-context', handle: 1, glx: true })).toBe('EmscriptenGLX');+ expect(graphicsPathFor({ kind: 'webgpu' })).toBe('WebGPU');+ expect(graphicsPathFor({ kind: 'default' })).toBeNull();+ });++ it('is unknown in the first hello and named in the one sent when the game starts', async () => {+ const sent: Array<{ t: string; graphics?: string | null }> = [];+ const handlers: Record<string, Array<() => void>> = {};+ const socket = {+ delivery: 'reliable-ordered', readyState: 'connecting',+ on(event: string, fn: () => void) { (handlers[event] ??= []).push(fn); return () => {}; },+ connect() {}, close() {},+ send(data: string) { sent.push(JSON.parse(data)); },+ } as unknown as PlatformSocket;+ setPlatform({ name: 'wechat', now: () => performance.now(), createSocket: () => socket } as unknown as PlatformAdapter);+ const { startDebugChannel, attachDebugChannel } = await import('../src/runtime/debugChannel');+ startDebugChannel({ url: 'ws://editor:1/?token=t' });+ (socket as { readyState: string }).readyState = 'open';+ for (const fn of handlers.open ?? []) fn();++ attachDebugChannel({ hasResource: () => false, onFrameEnd: () => () => {} } as unknown as App);+ const hellos = sent.filter((m) => m.t === 'hello');+ expect(hellos.map((h) => h.graphics)).toEqual([null, 'EmscriptenGLX']);+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex aac5dc8cf..77005de09 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1184,4 +1184,8 @@ export const NOTED = {{ note: '**EmscriptenGLX on WeChat.** A WeChat project can ship the engine linked with WeChat\'s EmscriptenGLX (Project Settings → WeChat → Render through EmscriptenGLX, off by default), which issues the engine\'s GL calls natively instead of through JavaScript: a draw-heavy scene spent about 12% less time rendering on an Android phone. It adds about 310KB of wasm and needs base library 3.8.12 on Android, or iOS in 高性能+ mode; any other host renders through WebGL2 as before, and the log says which. The engine is built once with `node build-tools/cli.js build -t wechat-glx`, which fetches WeChat\'s library at a pinned version and hash, and emsdk 4.0.10 beside the main one; an export that asks for it without it says so.' },'feat(settings): WeChat\'s EmscriptenGLX is a project setting':{ note: '**EmscriptenGLX on WeChat.** A WeChat project can ship the engine linked with WeChat\'s EmscriptenGLX (Project Settings → WeChat → Render through EmscriptenGLX, off by default), which issues the engine\'s GL calls natively instead of through JavaScript: a draw-heavy scene spent about 12% less time rendering on an Android phone. It adds about 310KB of wasm and needs base library 3.8.12 on Android, or iOS in 高性能+ mode; any other host renders through WebGL2 as before, and the log says which. The engine is built once with `node build-tools/cli.js build -t wechat-glx`, which fetches WeChat\'s library at a pinned version and hash, and emsdk 4.0.10 beside the main one; an export that asks for it without it says so.' },+ 'feat(debug): a connected build says which graphics API it draws through':+ { note: 'A connected development build says which graphics API it draws through — WebGL2, EmscriptenGLX or WebGPU — once its game has started: the Profiler shows it beside the device\'s controls, the Output Log notes it, and `device_targets` returns it as `graphics`. A WeChat build set to EmscriptenGLX reports WebGL2 on a host that does not offer it.' },+ 'feat(profiler): the Profiler shows which graphics API a device draws through':+ { note: 'A connected development build says which graphics API it draws through — WebGL2, EmscriptenGLX or WebGPU — once its game has started: the Profiler shows it beside the device\'s controls, the Output Log notes it, and `device_targets` returns it as `graphics`. A WeChat build set to EmscriptenGLX reports WebGL2 on a host that does not offer it.' },};