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(frame-debugger): a development build can be captured from the editor over the network
esengineafeb79bdc896
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 3538098f3..6ad9cd2a0 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -757,6 +757,12 @@ jobs:if: ${{ !cancelled() && matrix.shard == 1 && steps.toolchain.outcome == 'success' }}run: pnpm run verify:cooked+ # A development build dials the editor, and the frame debugger captures and+ # replays its frame over that socket — the web road and a mini-game's.+ - name: Check a development build can be frame-debugged from the editor+ if: ${{ !cancelled() && matrix.shard == 1 }}+ run: pnpm run verify:remote-capture+# A package whose points missed is a claim about a PICTURE, and the picture# has to leave the runner, or nobody can tell a real regression from a frame# the software rasteriser had not finished.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f3104acbf..9459bf781 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,10 @@ published separately; it ships inside the editor.## [Unreleased]+### Added++- The Frame Debugger can capture and replay a frame of a development build running outside the editor — a browser or a mini-game host, on this machine or another on the network: export with the Development configuration and "Frame debugger connection", then pick the device in the panel. Native apps cannot connect yet.+### Fixed- A Douyin recording the host ends on its own keeps its video, and an interruption is not counted as recorded time.diff --git a/desktop b/desktopindex 56340d6c5..0edacd351 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 56340d6c5e8a0dd3bc5a6d4cc6de632f9e017d34+Subproject commit 0edacd351714c5cadb7a8447059e5a7dfa1b41c0diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex 19f3f68d9..448b35bc0 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 115,"beta": 103,- "experimental": 2100,+ "experimental": 2110,"deprecated": 3},- "total": 2318,+ "total": 2328,"subsystems": [{"id": "ecs",diff --git a/package.json b/package.jsonindex 0a8356850..6df76dd13 100644--- a/package.json+++ b/package.json@@ -38,6 +38,7 @@"test": "vitest run --config vitest.engine.config.ts","verify:aot": "rm -rf .aot-verify && node pipeline/bin/estella.mjs export examples/ecs-basics --out .aot-verify && node tools/run-electron.mjs tools/launchers/headless-aot-verify.mjs .aot-verify","verify:cooked": "ESTELLA_COOK_FIXTURE=1 pnpm --filter @estella/pipeline exec vitest run tests/cooked-verify-fixture.test.ts && node tools/run-electron.mjs tools/launchers/headless-cooked-verify.mjs",+ "verify:remote-capture": "node tools/verify-remote-capture.mjs --platform web && node tools/verify-remote-capture.mjs --platform wechat","verify:hotupdate": "ESTELLA_HOTUPDATE_FIXTURE=1 pnpm --filter @estella/pipeline exec vitest run tests/hotupdate-verify-fixture.test.ts && node tools/run-electron.mjs tools/launchers/headless-hotupdate-verify.mjs"},"dependencies": {diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjsindex 18fe7c032..36361a886 100644--- a/pipeline/bin/estella.mjs+++ b/pipeline/bin/estella.mjs@@ -30,6 +30,9 @@ const USAGE = `usage: node pipeline/bin/estella.mjs export <projectDir> [options--json <file> also write the result here, for a caller that reads it back--enforce-budget fail (exit 1) when the package is over a size limit--minify minify the bundled scripts, as a shipping build does+ --debug-channel <url> a development build dials this editor address+ (ws://host:port/?token=…) so its frames can be captured;+ refused together with --minify--no-aot package without compiling the systems marked @compiled, sothe same project runs both ways and the frames are compared--steam-sdk <dir> desktop: a Steamworks SDK whose redistributable ships in the app@@ -847,6 +850,7 @@ try {iosSources: platform === 'ios' && templateDir ? iosTemplateSources(templateDir) : null,androidOutput: opts.output === 'project' ? 'project' : undefined,minify: opts.minify,+ ...(opts['debug-channel'] ? { debugChannel: { url: opts['debug-channel'] } } : {}),// `dev` is what the AOT step calls "do not compile" — the editor's preview// mode, reused here so there is one word for it (docs/REARCH_AOT.md §9)....(opts['no-aot'] ? { aotMode: 'dev' } : {}),diff --git a/pipeline/src/export/debugChannel.ts b/pipeline/src/export/debugChannel.tsnew file mode 100644index 000000000..848877135--- /dev/null+++ b/pipeline/src/export/debugChannel.ts@@ -0,0 +1,21 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file debugChannel.ts — whether a package carries the line back to the editor.+ */+import type { DebugChannelConfig } from 'esengine';++/**+ * The channel a package is built with, or none. A shipping export that was handed+ * one fails rather than drops it: a caller asking for both has a bug, and a build+ * that dials an editor must never reach a player.+ */+export function packagedDebugChannel(+ opts: { debugChannel?: DebugChannelConfig | null; minify?: boolean },+): DebugChannelConfig | undefined {+ if (!opts.debugChannel) return undefined;+ if (opts.minify) {+ throw new Error('a shipping build never carries a debug channel — export the Development config to debug on a device');+ }+ return { url: opts.debugChannel.url };+}diff --git a/pipeline/src/export/exportGame.ts b/pipeline/src/export/exportGame.tsindex ed9d42e3f..e737cba9f 100644--- a/pipeline/src/export/exportGame.ts+++ b/pipeline/src/export/exportGame.ts@@ -29,7 +29,8 @@ import { cookAssets, loadAssetGroups, type CookManifest, type Inclusion } from 'import { cookWorlds, streamedScenes } from '../world/cookWorld';import { buildAddressableManifest } from '../assets/addressableManifest';import { activeRemoteRoot } from '../../../sdk/src/asset/assetGroups';-import type { PackagedGameConfig } from 'esengine';+import type { DebugChannelConfig, PackagedGameConfig } from 'esengine';+import { packagedDebugChannel } from './debugChannel';import {DEFAULT_RUNTIME_CONFIG, packagedRuntimeFields, type RuntimeProjectConfig,} from '../project/runtimeConfig';@@ -304,7 +305,11 @@ function externalEngineImports(metafile: { outputs: Record<string, { imports?: {* for desktop (the Electron shell sizes its own window). */function indexHtml(title: string, map: EngineImportMap, look: SplashLook, orientation?: ScreenOrientation,+ debugChannel?: DebugChannelConfig,): string {+ // The editor a development build dials is the one address beyond 'self' the+ // page may connect to; a build without a channel lists none.+ const connect = debugChannel ? ` ${new URL(debugChannel.url).origin}` : '';// Every inline script on this page needs its hash listed, or the browser blocks it.const inlineScripts = [map.cspHash, ...(orientation ? [orientationLockCspHash(orientation)] : [])].map((h) => `'${h}'`)@@ -315,7 +320,7 @@ function indexHtml(<meta charset="UTF-8" /><metahttp-equiv="Content-Security-Policy"- content="default-src 'self'; script-src 'self' 'unsafe-eval' blob: ${inlineScripts}; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' data: blob:; worker-src 'self' blob:;"+ content="default-src 'self'; script-src 'self' 'unsafe-eval' blob: ${inlineScripts}; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' data: blob:${connect}; worker-src 'self' blob:;"/><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" /><title>${title}</title>@@ -517,6 +522,9 @@ export interface ExportGameOptions {/** Shipping config: minify the bundles, no sourcemap. Default off (dev). */minify?: boolean;sourcemap?: boolean;+ /** Where the editor listens for this development build; with `minify`, the+ * export fails (see `packagedDebugChannel`). */+ debugChannel?: DebugChannelConfig | null;/*** The project's runtime settings, derived ONCE from the manifest* (`runtimeConfigOf`) rather than re-listed per target. Every packaged build@@ -655,6 +663,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>// to take them as loose fields and each one had to remember the same list.const runtime = opts.runtime ?? DEFAULT_RUNTIME_CONFIG;const progress = opts.onProgress ?? (() => {});+ const debugChannel = packagedDebugChannel(opts);const scenes = await discoverProjectScenes(opts.root, opts.entryScene, opts.scenesDir, opts.excludeScenes);// Cutting a world is part of the common cook below, which the three pipelines@@ -699,6 +708,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>orientation,runtime,minify: opts.minify,+ debugChannel: opts.debugChannel,emcc: opts.emcc,aotMode: opts.aotMode,contentAddressed: opts.contentAddressed,@@ -738,6 +748,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>orientation,runtime,minify: opts.minify,+ debugChannel: opts.debugChannel,emcc: opts.emcc,aotMode: opts.aotMode,contentAddressed: opts.contentAddressed,@@ -1064,7 +1075,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>const look = await splashLook(opts.root, opts.splash, warnings);await writeFile(path.join(payloadDir, 'index.html'),- indexHtml(title, engineMap, look, platform === 'web' ? orientation : undefined),+ indexHtml(title, engineMap, look, platform === 'web' ? orientation : undefined, debugChannel),);}// Typed against the SDK's contract, so a field the runtimes read can never be@@ -1078,6 +1089,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>? { sideModules: sideModuleDeclarations(projectModules, platform) } : {}),...(aot ? { aot } : {}),...(world.worlds.length > 0 ? { worlds: world.worlds } : {}),+ ...(debugChannel ? { debugChannel } : {}),};await writeFile(path.join(payloadDir, 'game.config.json'), JSON.stringify(gameConfig, null, 2) + '\n');diff --git a/pipeline/src/export/exportMiniGame.ts b/pipeline/src/export/exportMiniGame.tsindex 0a628f934..f4d891b47 100644--- a/pipeline/src/export/exportMiniGame.ts+++ b/pipeline/src/export/exportMiniGame.ts@@ -28,6 +28,8 @@* have no import maps and a different module/asset model, so this is its* own path. Pure Node (esbuild + fs) — IPC wiring is in main.ts.*/+import type { DebugChannelConfig } from 'esengine';+import { packagedDebugChannel } from './debugChannel';import { loadEsbuild } from '../bundle/esbuildRuntime';import type { ProjectFeatures, ProjectPackaging } from '../project/format';import {@@ -288,6 +290,7 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {* generated boot passes the packaged slice of them to the vendor runtime. */runtime?: RuntimeProjectConfig;minify?: boolean;+ debugChannel?: DebugChannelConfig | null;/*** Where emcc is, for the systems a project marked `@compiled`* (docs/REARCH_AOT.md). Absent ⇒ found from the environment; a project that@@ -477,6 +480,8 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {? `, uiThemeOverrides: parseThemeOverrides(${JSON.stringify(v)})`: `, ${k}: ${JSON.stringify(v)}`)).join('');+ const debugChannel = packagedDebugChannel(opts);+ const debugArg = debugChannel ? `, debugChannel: ${JSON.stringify(debugChannel)}` : '';// esengine/minigame installs no platform until a host is named, so boot() names// one: a built-in points at a shipped module, a project vendor at a file beside// its own platform. Unjoined, the package builds and throws on the device.@@ -540,7 +545,7 @@ export async function exportMiniGame(profile: MiniGameExportProfile, opts: {`export function boot(engineFactory, sideModuleFactories) {\n` +(profile.platformInit ? ` ${profile.platformInit}();\n` : '') +(installsPlatform ? ` installMiniGamePlatform(__platformProfile);\n` : '') +- ` return ${profile.runtimeInit}({ engineFactory, engineWasmPath: ${JSON.stringify(engineWasmPath)}${runtimeLayout.sideModuleSuffix === '.wasm' ? '' : `, sideModuleSuffix: ${JSON.stringify(runtimeLayout.sideModuleSuffix)}`}, sideModuleFactories, sceneNames: ${JSON.stringify(scenes.map((s) => s.name))}, firstScene: ${JSON.stringify(sceneName)}${runtimeArgs}${projectDeclarations.length > 0 ? `, sideModules: ${JSON.stringify(projectDeclarations)}` : ''}${aotArg} });\n` ++ ` return ${profile.runtimeInit}({ engineFactory, engineWasmPath: ${JSON.stringify(engineWasmPath)}${runtimeLayout.sideModuleSuffix === '.wasm' ? '' : `, sideModuleSuffix: ${JSON.stringify(runtimeLayout.sideModuleSuffix)}`}, sideModuleFactories, sceneNames: ${JSON.stringify(scenes.map((s) => s.name))}, firstScene: ${JSON.stringify(sceneName)}${runtimeArgs}${projectDeclarations.length > 0 ? `, sideModules: ${JSON.stringify(projectDeclarations)}` : ''}${aotArg}${debugArg} });\n` +`}\n`;progress({ phase: 'Bundling game' });/** What each subsystem costs in the bundle — empty if esbuild wrote no metafile. */diff --git a/pipeline/src/export/sizeHistory.ts b/pipeline/src/export/sizeHistory.tsindex 7083a3e9a..c0e1458e1 100644--- a/pipeline/src/export/sizeHistory.ts+++ b/pipeline/src/export/sizeHistory.ts@@ -46,6 +46,7 @@ export const PACKAGING_SIZE_ROLE: Readonly<Record<string, keyof SizeSettings | 'platform: 'inert',config: 'minify',sourceMaps: 'sourcemap',+ frameDebugger: 'content',openFolder: 'inert',orientation: 'inert',assetCompression: 'compressTextures',diff --git a/pipeline/src/project/format.ts b/pipeline/src/project/format.tsindex 408afc8d3..2212006e4 100644--- a/pipeline/src/project/format.ts+++ b/pipeline/src/project/format.ts@@ -297,6 +297,8 @@ export interface ProjectPackaging {platform?: ExportPlatform;config?: 'development' | 'shipping';sourceMaps?: boolean;+ /** A development build dials the editor so the frame debugger can capture it. */+ frameDebugger?: boolean;openFolder?: boolean;/** Screen orientation for EVERY export target (WeChat game.json deviceOrientation,* the web/playable rotate-to-fit hint, the desktop window's aspect). Absent ⇒@@ -735,6 +737,7 @@ export function parseManifest(raw: unknown): ProjectManifest {if (p.config === 'development' || p.config === 'shipping') pkg.config = p.config;if (typeof p.appId === 'string' && p.appId !== '') pkg.appId = p.appId;if (typeof p.sourceMaps === 'boolean') pkg.sourceMaps = p.sourceMaps;+ if (typeof p.frameDebugger === 'boolean') pkg.frameDebugger = p.frameDebugger;if (typeof p.openFolder === 'boolean') pkg.openFolder = p.openFolder;if (typeof p.compressWasm === 'boolean') pkg.compressWasm = p.compressWasm;if (typeof p.engineSubpackage === 'boolean') pkg.engineSubpackage = p.engineSubpackage;diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 121cf17c5..662608150 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -96,6 +96,9 @@ importers:wasm-media-encoders:specifier: ^0.7.0version: 0.7.0+ ws:+ specifier: ^8.21.0+ version: 8.21.0zustand:specifier: ^5.0.14version: 5.0.14(@types/[email protected])([email protected])@@ -124,6 +127,9 @@ importers:'@types/react-dom':specifier: ^19.2.0version: 19.2.3(@types/[email protected])+ '@types/ws':+ specifier: ^8.18.1+ version: 8.18.1'@vitejs/plugin-react':specifier: ^6.0.2version: 6.0.2([email protected](@types/[email protected])([email protected])([email protected])([email protected]))diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex b19d25c05..74528bd7a 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,7 +1,7 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 91 beta · 1486 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1496 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -2556,6 +2556,11 @@ warnings: readonly string[]ThemeTokens```+## DEBUG_CHANNEL_PROTOCOL — const @experimental+```+1+```+## DEFAULT_ANIM_CLIP_PIVOT — const @experimental```AnimClipPivotData@@ -2695,6 +2700,24 @@ Int3 = 7Int4 = 8```+## DebugChannelConfig — interface @experimental+```+url: string+```++## DebugChannelMessage — type @experimental+```+| { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string }+```++## DebugChannelQuery — type @experimental+```+| { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number }+```+## DecalBakeOptions — interface @experimental```facing: number | undefined@@ -3667,6 +3690,12 @@ Point = 1Vortex = 2```+## FrameAssetNames — interface @experimental+```+material: (id: number) => string | null+texture: (renderId: number) => string | null+```+## FrameCaptureData — interface @experimental```drawCalls: DrawCallInfo[]@@ -3679,6 +3708,15 @@ scopes: ScopeCost[]systems: SystemCost[]```+## FrameDebugReport — interface @experimental+```+draws: DrawCallInfo[]+materials: Record<number, string>+names: Record<number, string>+passCount: number+textures: Record<number, string>+```+## FrameHistory — class @experimental```count: number@@ -3716,6 +3754,14 @@ scopes: readonly ScopeCost[]systems: readonly SystemCost[]```+## FrameReplayImage — interface @experimental+```+height: number+matchesCapture: boolean+pixels: Uint8ClampedArray<ArrayBufferLike>+width: number+```+## FrameSnapshot — interface @experimental```frameTimeMs: number@@ -5224,6 +5270,7 @@ achievements: string[] | undefinedaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedentryScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined@@ -6779,6 +6826,7 @@ aspectRatio: number | undefinedaudioConfig: AudioProjectConfig | undefinedcatalog: Catalog | undefinedcellDocuments: ReadonlyMap<string, SceneData> | undefined+debugChannel: DebugChannelConfig | undefinedfirstScene: stringmanifest: AddressableManifest | ManifestModel | null | undefinedmodule: ESEngineModule | null@@ -10011,6 +10059,11 @@ MotionDriver<AnimatorBlend2DMotion>(module: ESEngineModule, width: number, height: number, advance?: () => void | Promise<void>): Promise<FramePixels | null>```+## captureFrameReport — function @experimental+```+(app: App, nextFrame: NextFrame, pathOf?: (path: string) => string | null): Promise<FrameDebugReport | null>+```+## captureReflection — function @experimental```(at: readonly [number, number, number], bvh: Bvh, lookup: HitLookup, atlas: Float32Array, atlasSize: number, width: number, height: number, sky: SkyRadiance): CapturedPanorama@@ -10751,6 +10804,11 @@ FocusPlugin(report: CensusReport): string```+## frameDebugReport — function @experimental+```+(data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames): FrameDebugReport+```+## frameProfileOf — function @experimental```(frame: CapturedFrame): FrameProfile@@ -11378,7 +11436,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paramDefaultValue — function @experimental@@ -11836,6 +11894,11 @@ PrefabsPlugin(module: ESEngineModule, drawCallIndex: number, nextFrame: NextFrame, maxFrames?: number): Promise<ReplaySnapshot | null>```+## replayFrameDraw — function @experimental+```+(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null>+```+## reportDeviceLost — function @experimental```(reason: number, message: string): voiddiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex d5c3880f5..380453da5 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 96 beta · 1505 experimental · 3 deprecated+Symbols: 115 public · 96 beta · 1515 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -2564,6 +2564,11 @@ warnings: readonly string[]ThemeTokens```+## DEBUG_CHANNEL_PROTOCOL — const @experimental+```+1+```+## DEFAULT_ANIM_CLIP_PIVOT — const @experimental```AnimClipPivotData@@ -2703,6 +2708,24 @@ Int3 = 7Int4 = 8```+## DebugChannelConfig — interface @experimental+```+url: string+```++## DebugChannelMessage — type @experimental+```+| { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string }+```++## DebugChannelQuery — type @experimental+```+| { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number }+```+## DecalBakeOptions — interface @experimental```facing: number | undefined@@ -3675,6 +3698,12 @@ Point = 1Vortex = 2```+## FrameAssetNames — interface @experimental+```+material: (id: number) => string | null+texture: (renderId: number) => string | null+```+## FrameCaptureData — interface @experimental```drawCalls: DrawCallInfo[]@@ -3687,6 +3716,15 @@ scopes: ScopeCost[]systems: SystemCost[]```+## FrameDebugReport — interface @experimental+```+draws: DrawCallInfo[]+materials: Record<number, string>+names: Record<number, string>+passCount: number+textures: Record<number, string>+```+## FrameHistory — class @experimental```count: number@@ -3724,6 +3762,14 @@ scopes: readonly ScopeCost[]systems: readonly SystemCost[]```+## FrameReplayImage — interface @experimental+```+height: number+matchesCapture: boolean+pixels: Uint8ClampedArray<ArrayBufferLike>+width: number+```+## FrameSnapshot — interface @experimental```frameTimeMs: number@@ -5407,6 +5453,7 @@ achievements: string[] | undefinedaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedentryScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined@@ -6972,6 +7019,7 @@ aspectRatio: number | undefinedaudioConfig: AudioProjectConfig | undefinedcatalog: Catalog | undefinedcellDocuments: ReadonlyMap<string, SceneData> | undefined+debugChannel: DebugChannelConfig | undefinedfirstScene: stringmanifest: AddressableManifest | ManifestModel | null | undefinedmodule: ESEngineModule | null@@ -10219,6 +10267,11 @@ MotionDriver<AnimatorBlend2DMotion>(module: ESEngineModule, width: number, height: number, advance?: () => void | Promise<void>): Promise<FramePixels | null>```+## captureFrameReport — function @experimental+```+(app: App, nextFrame: NextFrame, pathOf?: (path: string) => string | null): Promise<FrameDebugReport | null>+```+## captureReflection — function @experimental```(at: readonly [number, number, number], bvh: Bvh, lookup: HitLookup, atlas: Float32Array, atlasSize: number, width: number, height: number, sky: SkyRadiance): CapturedPanorama@@ -10984,6 +11037,11 @@ FocusPlugin(report: CensusReport): string```+## frameDebugReport — function @experimental+```+(data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames): FrameDebugReport+```+## frameProfileOf — function @experimental```(frame: CapturedFrame): FrameProfile@@ -11621,7 +11679,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paramDefaultValue — function @experimental@@ -12079,6 +12137,11 @@ PrefabsPlugin(module: ESEngineModule, drawCallIndex: number, nextFrame: NextFrame, maxFrames?: number): Promise<ReplaySnapshot | null>```+## replayFrameDraw — function @experimental+```+(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null>+```+## reportDeviceLost — function @experimental```(reason: number, message: string): voiddiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 9fa2c815d..f7bc02c2f 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.node<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 93 beta · 1485 experimental · 3 deprecated+Symbols: 115 public · 93 beta · 1495 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -2551,6 +2551,11 @@ warnings: readonly string[]ThemeTokens```+## DEBUG_CHANNEL_PROTOCOL — const @experimental+```+1+```+## DEFAULT_ANIM_CLIP_PIVOT — const @experimental```AnimClipPivotData@@ -2690,6 +2695,24 @@ Int3 = 7Int4 = 8```+## DebugChannelConfig — interface @experimental+```+url: string+```++## DebugChannelMessage — type @experimental+```+| { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string }+```++## DebugChannelQuery — type @experimental+```+| { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number }+```+## DecalBakeOptions — interface @experimental```facing: number | undefined@@ -3662,6 +3685,12 @@ Point = 1Vortex = 2```+## FrameAssetNames — interface @experimental+```+material: (id: number) => string | null+texture: (renderId: number) => string | null+```+## FrameCaptureData — interface @experimental```drawCalls: DrawCallInfo[]@@ -3674,6 +3703,15 @@ scopes: ScopeCost[]systems: SystemCost[]```+## FrameDebugReport — interface @experimental+```+draws: DrawCallInfo[]+materials: Record<number, string>+names: Record<number, string>+passCount: number+textures: Record<number, string>+```+## FrameHistory — class @experimental```count: number@@ -3711,6 +3749,14 @@ scopes: readonly ScopeCost[]systems: readonly SystemCost[]```+## FrameReplayImage — interface @experimental+```+height: number+matchesCapture: boolean+pixels: Uint8ClampedArray<ArrayBufferLike>+width: number+```+## FrameSnapshot — interface @experimental```frameTimeMs: number@@ -5219,6 +5265,7 @@ achievements: string[] | undefinedaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedentryScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined@@ -6774,6 +6821,7 @@ aspectRatio: number | undefinedaudioConfig: AudioProjectConfig | undefinedcatalog: Catalog | undefinedcellDocuments: ReadonlyMap<string, SceneData> | undefined+debugChannel: DebugChannelConfig | undefinedfirstScene: stringmanifest: AddressableManifest | ManifestModel | null | undefinedmodule: ESEngineModule | null@@ -10006,6 +10054,11 @@ MotionDriver<AnimatorBlend2DMotion>(module: ESEngineModule, width: number, height: number, advance?: () => void | Promise<void>): Promise<FramePixels | null>```+## captureFrameReport — function @experimental+```+(app: App, nextFrame: NextFrame, pathOf?: (path: string) => string | null): Promise<FrameDebugReport | null>+```+## captureReflection — function @experimental```(at: readonly [number, number, number], bvh: Bvh, lookup: HitLookup, atlas: Float32Array, atlasSize: number, width: number, height: number, sky: SkyRadiance): CapturedPanorama@@ -10746,6 +10799,11 @@ FocusPlugin(report: CensusReport): string```+## frameDebugReport — function @experimental+```+(data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames): FrameDebugReport+```+## frameProfileOf — function @experimental```(frame: CapturedFrame): FrameProfile@@ -11383,7 +11441,7 @@ NodePlatformAdapter## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paramDefaultValue — function @experimental@@ -11841,6 +11899,11 @@ PrefabsPlugin(module: ESEngineModule, drawCallIndex: number, nextFrame: NextFrame, maxFrames?: number): Promise<ReplaySnapshot | null>```+## replayFrameDraw — function @experimental+```+(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null>+```+## reportDeviceLost — function @experimental```(reason: number, message: string): voiddiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex db65f477b..e5023c226 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1,7 +1,7 @@# API surface — esengine/minigame<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 91 beta · 1507 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1517 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -2551,6 +2551,11 @@ warnings: readonly string[]ThemeTokens```+## DEBUG_CHANNEL_PROTOCOL — const @experimental+```+1+```+## DEFAULT_ANIM_CLIP_PIVOT — const @experimental```AnimClipPivotData@@ -2690,6 +2695,24 @@ Int3 = 7Int4 = 8```+## DebugChannelConfig — interface @experimental+```+url: string+```++## DebugChannelMessage — type @experimental+```+| { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string }+```++## DebugChannelQuery — type @experimental+```+| { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number }+```+## DecalBakeOptions — interface @experimental```facing: number | undefined@@ -3662,6 +3685,12 @@ Point = 1Vortex = 2```+## FrameAssetNames — interface @experimental+```+material: (id: number) => string | null+texture: (renderId: number) => string | null+```+## FrameCaptureData — interface @experimental```drawCalls: DrawCallInfo[]@@ -3674,6 +3703,15 @@ scopes: ScopeCost[]systems: SystemCost[]```+## FrameDebugReport — interface @experimental+```+draws: DrawCallInfo[]+materials: Record<number, string>+names: Record<number, string>+passCount: number+textures: Record<number, string>+```+## FrameHistory — class @experimental```count: number@@ -3711,6 +3749,14 @@ scopes: readonly ScopeCost[]systems: readonly SystemCost[]```+## FrameReplayImage — interface @experimental+```+height: number+matchesCapture: boolean+pixels: Uint8ClampedArray<ArrayBufferLike>+width: number+```+## FrameSnapshot — interface @experimental```frameTimeMs: number@@ -5171,6 +5217,7 @@ url: stringaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedengineFactory: (opts: unknown) => Promise<ESEngineModule>engineWasmPath: string@@ -5482,6 +5529,7 @@ achievements: string[] | undefinedaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedentryScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined@@ -7037,6 +7085,7 @@ aspectRatio: number | undefinedaudioConfig: AudioProjectConfig | undefinedcatalog: Catalog | undefinedcellDocuments: ReadonlyMap<string, SceneData> | undefined+debugChannel: DebugChannelConfig | undefinedfirstScene: stringmanifest: AddressableManifest | ManifestModel | null | undefinedmodule: ESEngineModule | null@@ -10275,6 +10324,11 @@ MotionDriver<AnimatorBlend2DMotion>(module: ESEngineModule, width: number, height: number, advance?: () => void | Promise<void>): Promise<FramePixels | null>```+## captureFrameReport — function @experimental+```+(app: App, nextFrame: NextFrame, pathOf?: (path: string) => string | null): Promise<FrameDebugReport | null>+```+## captureReflection — function @experimental```(at: readonly [number, number, number], bvh: Bvh, lookup: HitLookup, atlas: Float32Array, atlasSize: number, width: number, height: number, sky: SkyRadiance): CapturedPanorama@@ -11020,6 +11074,11 @@ FocusPlugin(report: CensusReport): string```+## frameDebugReport — function @experimental+```+(data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames): FrameDebugReport+```+## frameProfileOf — function @experimental```(frame: CapturedFrame): FrameProfile@@ -11657,7 +11716,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paramDefaultValue — function @experimental@@ -12115,6 +12174,11 @@ PrefabsPlugin(module: ESEngineModule, drawCallIndex: number, nextFrame: NextFrame, maxFrames?: number): Promise<ReplaySnapshot | null>```+## replayFrameDraw — function @experimental+```+(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null>+```+## reportDeviceLost — function @experimental```(reason: number, message: string): voiddiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 055fe14d0..09eb61ab2 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1,7 +1,7 @@# API surface — esengine/wechat<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 91 beta · 1498 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1508 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -2551,6 +2551,11 @@ warnings: readonly string[]ThemeTokens```+## DEBUG_CHANNEL_PROTOCOL — const @experimental+```+1+```+## DEFAULT_ANIM_CLIP_PIVOT — const @experimental```AnimClipPivotData@@ -2690,6 +2695,24 @@ Int3 = 7Int4 = 8```+## DebugChannelConfig — interface @experimental+```+url: string+```++## DebugChannelMessage — type @experimental+```+| { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string }+```++## DebugChannelQuery — type @experimental+```+| { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number }+```+## DecalBakeOptions — interface @experimental```facing: number | undefined@@ -3662,6 +3685,12 @@ Point = 1Vortex = 2```+## FrameAssetNames — interface @experimental+```+material: (id: number) => string | null+texture: (renderId: number) => string | null+```+## FrameCaptureData — interface @experimental```drawCalls: DrawCallInfo[]@@ -3674,6 +3703,15 @@ scopes: ScopeCost[]systems: SystemCost[]```+## FrameDebugReport — interface @experimental+```+draws: DrawCallInfo[]+materials: Record<number, string>+names: Record<number, string>+passCount: number+textures: Record<number, string>+```+## FrameHistory — class @experimental```count: number@@ -3711,6 +3749,14 @@ scopes: readonly ScopeCost[]systems: readonly SystemCost[]```+## FrameReplayImage — interface @experimental+```+height: number+matchesCapture: boolean+pixels: Uint8ClampedArray<ArrayBufferLike>+width: number+```+## FrameSnapshot — interface @experimental```frameTimeMs: number@@ -5226,6 +5272,7 @@ achievements: string[] | undefinedaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedentryScene: stringhotUpdate: { remoteRoot?: string; persistUpdateKey?: string; } | undefined@@ -6781,6 +6828,7 @@ aspectRatio: number | undefinedaudioConfig: AudioProjectConfig | undefinedcatalog: Catalog | undefinedcellDocuments: ReadonlyMap<string, SceneData> | undefined+debugChannel: DebugChannelConfig | undefinedfirstScene: stringmanifest: AddressableManifest | ManifestModel | null | undefinedmodule: ESEngineModule | null@@ -9323,6 +9371,7 @@ y: numberaot: { module: string; manifest: AotManifest; } | undefinedaudioConfig: AudioProjectConfig | undefinedcolorSpace: "gamma" | "linear" | undefined+debugChannel: DebugChannelConfig | undefineddepthLayers: number | undefinedengineFactory: (opts: unknown) => Promise<ESEngineModule>engineWasmPath: string | undefined@@ -10035,6 +10084,11 @@ MotionDriver<AnimatorBlend2DMotion>(module: ESEngineModule, width: number, height: number, advance?: () => void | Promise<void>): Promise<FramePixels | null>```+## captureFrameReport — function @experimental+```+(app: App, nextFrame: NextFrame, pathOf?: (path: string) => string | null): Promise<FrameDebugReport | null>+```+## captureReflection — function @experimental```(at: readonly [number, number, number], bvh: Bvh, lookup: HitLookup, atlas: Float32Array, atlasSize: number, width: number, height: number, sky: SkyRadiance): CapturedPanorama@@ -10775,6 +10829,11 @@ FocusPlugin(report: CensusReport): string```+## frameDebugReport — function @experimental+```+(data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames): FrameDebugReport+```+## frameProfileOf — function @experimental```(frame: CapturedFrame): FrameProfile@@ -11412,7 +11471,7 @@ MeshRendererPlugin## packagedRuntimeInit — function @experimental```-(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; }+(config: Pick<PackagedGameConfig, "physicsEnabled" | "physicsConfig" | "audioConfig" | "uiTheme" | "uiThemeColors" | "achievements" | "steamAppId" | "screenFit" | "aot" | "debugChannel">): { physicsEnabled?: boolean; physicsConfig?: Physics2DPluginConfig; audioConfig?: AudioProjectConfig; uiTheme?: "light"; uiThemeOverrides?: ThemeOverrides; achievements?: string[]; steamAppId?: number; screenFit?: PackagedGameConfig["screenFit"]; aot?: PackagedGameConfig["aot"]; debugChannel?: DebugChannelConfig; }```## paramDefaultValue — function @experimental@@ -11870,6 +11929,11 @@ PrefabsPlugin(module: ESEngineModule, drawCallIndex: number, nextFrame: NextFrame, maxFrames?: number): Promise<ReplaySnapshot | null>```+## replayFrameDraw — function @experimental+```+(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null>+```+## reportDeviceLost — function @experimental```(reason: number, message: string): voiddiff --git a/sdk/src/core-content.ts b/sdk/src/core-content.tsindex 7cffc863b..5d9b1be0e 100644--- a/sdk/src/core-content.ts+++ b/sdk/src/core-content.ts@@ -443,6 +443,12 @@ export {type PackagedAssetSourceOptions,type PackagedGameConfig,} from './runtime/packagedRuntime';+export {+ DEBUG_CHANNEL_PROTOCOL,+ type DebugChannelConfig,+ type DebugChannelMessage,+ type DebugChannelQuery,+} from './runtime/debugChannel';// =============================================================================// Previewdiff --git a/sdk/src/core-render.ts b/sdk/src/core-render.tsindex 70a2051a7..e271f4629 100644--- a/sdk/src/core-render.ts+++ b/sdk/src/core-render.ts@@ -253,6 +253,14 @@ export {type NextFrame,type ReplaySnapshot,} from './render/frameCapture';+export {+ captureFrameReport,+ frameDebugReport,+ replayFrameDraw,+ type FrameAssetNames,+ type FrameDebugReport,+ type FrameReplayImage,+} from './render/frameDebugReport';// =============================================================================// RenderTexture APIdiff --git a/sdk/src/render/frameDebugReport.ts b/sdk/src/render/frameDebugReport.tsnew file mode 100644index 000000000..64b818a71--- /dev/null+++ b/sdk/src/render/frameDebugReport.ts@@ -0,0 +1,96 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file frameDebugReport.ts+ * @brief One captured frame as a frame debugger shows it, and one replayed draw,+ * built inside the game's own realm and carried out as plain data.+ *+ * The editor's viewport, its Play realm and a device running a debug build all+ * answer the frame debugger through these two functions, so a capture reads the+ * same wherever it was taken.+ */+import type { App } from '../app/app';+import { Assets } from '../asset/AssetPlugin';+import { Name } from '../ecs/component';+import { captureFrame, replayDraw, type DrawCallInfo, type FrameCaptureData, type NextFrame } from './frameCapture';++export interface FrameDebugReport {+ passCount: number;+ draws: DrawCallInfo[];+ /** Every entity a draw lists, by id; absent where the entity has no Name. */+ names: Record<number, string>;+ /** The load paths behind the frame's material and texture ids, where an asset+ * is behind them. */+ materials: Record<number, string>;+ textures: Record<number, string>;+}++/** How a realm names what a draw bound: its Assets, asked by id. */+export interface FrameAssetNames {+ material(id: number): string | null;+ texture(renderId: number): string | null;+}++/** One replayed draw: the pass up to and including it, as RGBA rows top-down. */+export interface FrameReplayImage {+ width: number;+ height: number;+ pixels: Uint8ClampedArray;+ matchesCapture: boolean;+}++export function frameDebugReport(+ data: FrameCaptureData, nameOf: (entity: number) => string | null, assets?: FrameAssetNames,+): FrameDebugReport {+ const names: Record<number, string> = {};+ const materials: Record<number, string> = {};+ const textures: Record<number, string> = {};+ for (const draw of data.drawCalls) {+ if (assets && draw.materialId !== 0 && !(draw.materialId in materials)) {+ const path = assets.material(draw.materialId);+ if (path) materials[draw.materialId] = path;+ }+ for (const id of draw.textures) {+ if (!assets || id === 0 || id in textures) continue;+ const path = assets.texture(id);+ if (path) textures[id] = path;+ }+ for (const e of draw.entities) {+ if (e in names) continue;+ const name = nameOf(e);+ if (name) names[e] = name;+ }+ }+ return { passCount: data.passCount, draws: data.drawCalls, names, materials, textures };+}++/**+ * Capture @p app's next whole frame; null when it drew nothing. @p pathOf turns an+ * asset's load path into the one its reader knows it by.+ */+export async function captureFrameReport(+ app: App, nextFrame: NextFrame, pathOf: (path: string) => string | null = (p) => p,+): Promise<FrameDebugReport | null> {+ const m = app.wasmModule;+ if (!m) return null;+ const cap = await captureFrame(m, nextFrame);+ if (!cap) return null;+ const assets = app.hasResource(Assets) ? app.getResource(Assets) : null;+ const path = (p: string | null | undefined): string | null => (p ? pathOf(p) : null);+ return frameDebugReport(cap,+ (e) => (app.world.tryGet(e as never, Name) as { value?: string } | null)?.value || null,+ {+ material: (id) => path(assets?.pathForHandle('material', id)),+ texture: (id) => path(assets?.pathForRenderedTexture(id)),+ });+}++/** The last capture's pass in @p app, drawn up to and including @p drawIndex. */+export async function replayFrameDraw(app: App, drawIndex: number, nextFrame: NextFrame): Promise<FrameReplayImage | null> {+ const m = app.wasmModule;+ const snap = m ? await replayDraw(m, drawIndex, nextFrame) : null;+ return snap && {+ width: snap.image.width, height: snap.image.height,+ pixels: snap.image.data, matchesCapture: snap.matchesCapture,+ };+}diff --git a/sdk/src/runtime/debugChannel.ts b/sdk/src/runtime/debugChannel.tsnew file mode 100644index 000000000..15eee7afe--- /dev/null+++ b/sdk/src/runtime/debugChannel.ts@@ -0,0 +1,123 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file debugChannel.ts+ * @brief A development build's line back to the editor that exported it, over+ * which the editor's frame debugger captures the device's frames.+ *+ * Only a build whose config carries `debugChannel` opens one, and only a+ * development export writes that field. The device dials out: a phone or a+ * 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 { getPlatform } from '../platform/base';+import type { PlatformSocket } from '../platform/types';+import type { NextFrame } from '../render/frameCapture';+import { captureFrameReport, replayFrameDraw } from '../render/frameDebugReport';+import { log } from '../util/logger';++export const DEBUG_CHANNEL_PROTOCOL = 1;++/** The editor's address as a development export writes it into the config. */+export interface DebugChannelConfig {+ /** `ws://<editor host>:<port>/?token=<token>` */+ url: string;+}++export type DebugChannelQuery =+ | { t: 'query'; reqId: number; kind: 'frameCapture' }+ | { t: 'query'; reqId: number; kind: 'frameReplay'; drawIndex: number };++/**+ * What a device sends. A replay's pixels follow their `reply` as the very next+ * frame, binary, rather than inside it: a 1080p pass is 8MB of RGBA, and text+ * would add a third to every byte of it.+ */+export type DebugChannelMessage =+ | { t: 'hello'; v: number; platform: string; title: string }+ | { t: 'reply'; reqId: number; data: unknown; pixels?: boolean }+ | { t: 'reply'; reqId: number; error: string };++const RECONNECT_MS = 3000;++/** Resolves once @p app has finished a frame and the task that drew it has run. */+function appFrame(app: App): NextFrame {+ return () => new Promise((resolve) => {+ const off = app.onFrameEnd(() => {+ off();+ setTimeout(resolve, 0);+ });+ });+}++/**+ * Keep a channel to the editor open for as long as @p app runs, dialling again+ * when it drops — the editor restarts far more often than a debug session ends.+ * Returns the disposer.+ */+export function openDebugChannel(app: App, config: DebugChannelConfig, title = ''): () => void {+ const platform = getPlatform();+ if (!platform.createSocket) {+ log.warn('debug', `this platform has no socket, so the editor cannot reach this build (${platform.name})`);+ return () => {};+ }+ const nextFrame = appFrame(app);+ let socket: PlatformSocket | null = null;+ let retry: ReturnType<typeof setTimeout> | null = null;+ let closed = false;++ const answer = async (s: PlatformSocket, q: DebugChannelQuery): Promise<void> => {+ const reply = (m: DebugChannelMessage): void => s.send(JSON.stringify(m));+ try {+ if (q.kind === 'frameCapture') {+ reply({ t: 'reply', reqId: q.reqId, data: await captureFrameReport(app, nextFrame) });+ return;+ }+ const image = await replayFrameDraw(app, q.drawIndex, nextFrame);+ if (!image) {+ reply({ t: 'reply', reqId: q.reqId, data: null });+ return;+ }+ const { pixels, ...rest } = image;+ reply({ t: 'reply', reqId: q.reqId, data: rest, pixels: true });+ s.send(pixels.buffer.byteLength === pixels.byteLength+ ? pixels.buffer as ArrayBuffer+ : pixels.slice().buffer as ArrayBuffer);+ } catch (e) {+ reply({ t: 'reply', reqId: q.reqId, error: e instanceof Error ? e.message : String(e) });+ }+ };++ const dial = (): void => {+ retry = null;+ if (closed) return;+ const s = platform.createSocket!({ url: config.url });+ socket = s;+ s.on('open', () => {+ const hello: DebugChannelMessage = { t: 'hello', v: DEBUG_CHANNEL_PROTOCOL, platform: platform.name, title };+ s.send(JSON.stringify(hello));+ log.info('debug', 'connected to the editor');+ });+ s.on('message', (data) => {+ if (typeof data !== 'string') return;+ let q: DebugChannelQuery;+ try { q = JSON.parse(data) as DebugChannelQuery; } catch { return; }+ if (q.t === 'query') void answer(s, q);+ });+ s.on('close', () => {+ if (socket === s) socket = null;+ if (!closed && retry === null) retry = setTimeout(dial, RECONNECT_MS);+ });+ s.on('error', () => { /* a close follows, and it redials */ });+ s.connect();+ };++ dial();+ return () => {+ closed = true;+ if (retry !== null) clearTimeout(retry);+ socket?.close();+ socket = null;+ };+}diff --git a/sdk/src/runtime/miniGameRuntime.ts b/sdk/src/runtime/miniGameRuntime.tsindex 6bbe5d573..f7d3b1e43 100644--- a/sdk/src/runtime/miniGameRuntime.ts+++ b/sdk/src/runtime/miniGameRuntime.ts@@ -31,6 +31,7 @@ import { createMiniGameSideModuleHost, type MiniGameSideModuleFactories } from 'import type { Physics2DPluginConfig } from '../physics/PhysicsTypes';import type { SceneData } from '../scene/scene';import type { AotManifest } from '../ecs/aot/AotSystems';+import type { DebugChannelConfig } from './debugChannel';import { log } from '../util/logger';import { Schedule, defineSystem } from '../ecs/system';import type { App } from '../app/app';@@ -162,6 +163,7 @@ export interface MiniGameRuntimeConfig {* a package file and nothing else, which is also why the seam instantiates.*/aot?: { module: string; manifest: AotManifest };+ debugChannel?: DebugChannelConfig;}/**@@ -296,6 +298,7 @@ export async function initMiniGameRuntime(config: MiniGameRuntimeConfig): PromisaudioConfig: config.audioConfig,aspectRatio: canvas.width / canvas.height,...(config.aot ? { aot: config.aot } : {}),+ ...(config.debugChannel ? { debugChannel: config.debugChannel } : {}),});progress.reach('ready');diff --git a/sdk/src/runtime/packagedRuntime.ts b/sdk/src/runtime/packagedRuntime.tsindex 2a3c658bd..c9ff39029 100644--- a/sdk/src/runtime/packagedRuntime.ts+++ b/sdk/src/runtime/packagedRuntime.ts@@ -12,6 +12,7 @@* the bytes arrive, so the same code serves both realms.*/+import type { DebugChannelConfig } from './debugChannel';import { extractUuid } from '../asset/AssetRegistry';import { platformReadTextFile, platformLoadImagePixels } from '../platform';import { ManifestModel, type AddressableManifest } from '../asset/AddressableManifest';@@ -111,6 +112,9 @@ export interface PackagedGameConfig {* runtime reads presence and needs no mode flag.*/aot?: { module: string; manifest: AotManifest };+ /** Where the editor that made this development build listens for it. Never+ * written by a shipping export. */+ debugChannel?: DebugChannelConfig;}/** The packaged realm's resolved asset index — manifest, catalog, resolution. */@@ -200,7 +204,7 @@ export function packagedAppOptions(export function packagedRuntimeInit(config: Pick<PackagedGameConfig,'physicsEnabled' | 'physicsConfig' | 'audioConfig' | 'uiTheme' | 'uiThemeColors'- | 'achievements' | 'steamAppId' | 'screenFit' | 'aot'>,+ | 'achievements' | 'steamAppId' | 'screenFit' | 'aot' | 'debugChannel'>,): {physicsEnabled?: boolean;physicsConfig?: Physics2DPluginConfig;@@ -211,6 +215,7 @@ export function packagedRuntimeInit(steamAppId?: number;screenFit?: PackagedGameConfig['screenFit'];aot?: PackagedGameConfig['aot'];+ debugChannel?: DebugChannelConfig;} {return {physicsEnabled: config.physicsEnabled,@@ -227,6 +232,7 @@ export function packagedRuntimeInit(// is a host the next one never reaches, and this one reached none of the// native road until it was asked for by hand.aot: config.aot,+ debugChannel: config.debugChannel,};}diff --git a/sdk/src/runtime/runtimeLoader.ts b/sdk/src/runtime/runtimeLoader.tsindex 45ac8a286..a779da24a 100644--- a/sdk/src/runtime/runtimeLoader.ts+++ b/sdk/src/runtime/runtimeLoader.ts@@ -44,6 +44,7 @@ import { flushPendingRegistrations } from '../app/app';import { installHotUpdateRebind } from '../hotUpdateRebind';import { requireResourceManager } from '../wasm/resourceManager';import { log } from '../util/logger';+import { openDebugChannel, type DebugChannelConfig } from './debugChannel';import type { AotManifest } from '../ecs/aot/AotSystems';import { type RuntimeAssetSource, type TextureParams } from './runtimeAssets';import type { SpineAssetInfo } from '../spine/loadSpineScene';@@ -799,6 +800,7 @@ export interface RuntimeInitConfig {* exists yet to be left behind in the wrong memory.*/aot?: { module: string | BufferSource; manifest: AotManifest };+ debugChannel?: DebugChannelConfig;}export async function initRuntime(config: RuntimeInitConfig): Promise<void> {@@ -814,6 +816,8 @@ export async function initRuntime(config: RuntimeInitConfig): Promise<void> {log.info('runtime', `AOT: ${installed} compiled system(s) installed`);}+ if (config.debugChannel) openDebugChannel(app, config.debugChannel);+// Install the per-App runtime Assets up front (scene loads reuse it) and// hand it the manifest so on-demand loadGroup works from the first frame.// The catalog rides the same first-creation moment (later ensure callsdiff --git a/tools/launchers/minigameHost.mjs b/tools/launchers/minigameHost.mjsindex 4e602775a..140bebb8e 100644--- a/tools/launchers/minigameHost.mjs+++ b/tools/launchers/minigameHost.mjs@@ -111,19 +111,29 @@ export const HOST_PAGE = (entry, failSubpackage = null) => `<!doctype html>o.success && o.success({ data, statusCode: r.status });}).catch((e) => o.fail && o.fail({ errMsg: String(e) })).finally(() => o.complete && o.complete());},- // Audio and sockets are stubs on purpose: a launch smoke asks whether the- // package starts and draws, and a silent stub cannot fake either answer.+ // Audio is a stub on purpose: a launch smoke asks whether the package starts+ // and draws, and a silent stub cannot fake either answer.createInnerAudioContext: () => ({play: noop, pause: noop, stop: noop, destroy: noop, seek: noop,onPlay: noop, onPause: noop, onStop: noop, onEnded: noop, onError: noop, onCanplay: noop,offPlay: noop, offPause: noop, offStop: noop, offEnded: noop, offError: noop, offCanplay: noop,src: '', loop: false, volume: 1, autoplay: false, currentTime: 0, duration: 0, paused: true,}),- connectSocket: () => ({- send: noop, close: noop,- onOpen: noop, onClose: noop, onError: noop, onMessage: noop,- offOpen: noop, offClose: noop, offError: noop, offMessage: noop,- }),+ // A real socket, in the SocketTask shape: a development build dials the+ // editor through it, and a stub would pass that check without a byte moving.+ connectSocket: (o) => {+ const ws = new WebSocket(o.url, o.protocols);+ ws.binaryType = 'arraybuffer';+ return {+ send: (m) => { ws.send(m.data); m.success && m.success(); },+ close: (m = {}) => ws.close(m.code, m.reason),+ onOpen: (cb) => ws.addEventListener('open', () => cb({})),+ onClose: (cb) => ws.addEventListener('close', (e) => cb({ code: e.code, reason: e.reason })),+ onError: (cb) => ws.addEventListener('error', () => cb({ errMsg: 'connectSocket:fail' })),+ onMessage: (cb) => ws.addEventListener('message', (e) => cb({ data: e.data })),+ offOpen: noop, offClose: noop, offError: noop, offMessage: noop,+ };+ },onTouchStart: noop, onTouchMove: noop, onTouchEnd: noop,offTouchStart: noop, offTouchMove: noop, offTouchEnd: noop,onTouchCancel: noop, offTouchCancel: noop,diff --git a/tools/lib/electronRun.mjs b/tools/lib/electronRun.mjsindex 3d87f8f48..41131d78d 100644--- a/tools/lib/electronRun.mjs+++ b/tools/lib/electronRun.mjs@@ -20,7 +20,7 @@import { createRequire } from 'node:module';import path from 'node:path';import { fileURLToPath } from 'node:url';-import { runTool } from './runTool.mjs';+import { runTool, spawnTool } from './runTool.mjs';const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');@@ -62,13 +62,25 @@ export const NEEDS_XVFB = process.platform === 'linux'* nested package has its own. `env` merges over what this adds, never replacing.*/export function runElectron(args, { via = 'pnpm', env, ...options } = {}) {+ const [cmd, argv, opts] = electronCommand(args, { via, env, ...options });+ return runTool(cmd, argv, opts);+}++/** {@link runElectron} without waiting: for a caller that must keep answering+ * the process while it runs. */+export function spawnElectron(args, { via = 'pnpm', env, ...options } = {}) {+ const [cmd, argv, opts] = electronCommand(args, { via, env, ...options });+ return spawnTool(cmd, argv, opts);+}++function electronCommand(args, { via, env, ...options }) {ensureElectronBinary();const electron = via === 'npx' ? ['npx', 'electron'] : ['pnpm', 'exec', 'electron'];const [cmd, ...rest] = NEEDS_XVFB? ['xvfb-run', '-a', '--server-args', SCREEN, ...electron]: electron;- return runTool(cmd, [...rest, ...args], {+ return [cmd, [...rest, ...args], {...options,env: { ...process.env, ELECTRON_DISABLE_SANDBOX: '1', ...env },- });+ }];}diff --git a/tools/lib/runTool.mjs b/tools/lib/runTool.mjsindex 9ce677558..bb7e0c594 100644--- a/tools/lib/runTool.mjs+++ b/tools/lib/runTool.mjs@@ -3,7 +3,7 @@/*** @file runTool.mjs — spawn a workspace CLI (pnpm, npx, xvfb-run) on every OS.*/-import { spawnSync } from 'node:child_process';+import { spawn, spawnSync } from 'node:child_process';/** Windows installs pnpm and npx as `.cmd` shims. Node refuses to spawn either* directly (ENOENT for the bare name, EINVAL for the suffix), so they have to@@ -39,3 +39,11 @@ export function runTool(cmd, args, options = {}) {const why = `${cmd} did not start: ${r.error.code ?? r.error.message}`;return { ...r, status: r.status ?? 127, stderr: `${r.stderr ?? ''}${why}\n` };}++/** {@link runTool} without waiting, for a caller that must keep answering the+ * process while it runs. */+export function spawnTool(cmd, args, options = {}) {+ return VIA_SHELL+ ? spawn([cmd, ...args].map(quote).join(' '), { ...options, shell: true })+ : spawn(cmd, args, options);+}diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 28c82cb44..c5f9d67d0 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1056,4 +1056,8 @@ export const NOTED = {{ internal: 'a release criterion\'s own measuring conditions; the engine is unchanged' },'fix(recorder): a Douyin recording the host ends on its own keeps its video':{ note: 'A Douyin recording the host ends on its own keeps its video, and an interruption is not counted as recorded time.' },+ 'feat(frame-debugger): a development build can be captured from the editor over the network':+ { note: 'The Frame Debugger can capture and replay a frame of a development build running outside the editor — a browser or a mini-game host, on this machine or another on the network: export with the Development configuration and "Frame debugger connection", then pick the device in the panel. Native apps cannot connect yet.' },+ 'feat(frame-debugger): capture a frame from a development build running elsewhere':+ { note: 'The Frame Debugger can capture and replay a frame of a development build running outside the editor — a browser or a mini-game host, on this machine or another on the network: export with the Development configuration and "Frame debugger connection", then pick the device in the panel. Native apps cannot connect yet.' },};diff --git a/tools/verify-remote-capture.mjs b/tools/verify-remote-capture.mjsnew file mode 100644index 000000000..14a59c9e9--- /dev/null+++ b/tools/verify-remote-capture.mjs@@ -0,0 +1,130 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file verify-remote-capture.mjs — a development build dials the editor, and the+ * editor captures and replays one of its frames.+ *+ * The editor's own server (desktop/shared/debugChannelServer.mjs) listens; a golden+ * project is exported with the channel and opened the way a player opens it; the+ * frame comes back over the socket. Asked of the package, not of the editor's+ * realms, because a capture that only works in-process is the one this exists to+ * go beyond. Also asked: a dial with the wrong token is refused, and a shipping+ * export will not carry a channel at all.+ *+ * node tools/verify-remote-capture.mjs [--project input-actions] [--platform web]+ */+import { spawnSync } from 'node:child_process';+import { createRequire } from 'node:module';+import { mkdirSync, rmSync, readFileSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { projectDir, ROOT } from './goldenProjects.mjs';+import { spawnElectron } from './lib/electronRun.mjs';+import { createDebugChannelServer } from '../desktop/shared/debugChannelServer.mjs';++const argv = process.argv.slice(2);+const arg = (name, fallback) => {+ const i = argv.indexOf(`--${name}`);+ return i >= 0 ? argv[i + 1] : fallback;+};+const PROJECT = arg('project', 'input-actions');+const PLATFORM = arg('platform', 'web');+const LAUNCHER = { web: 'launch-export.mjs', wechat: 'launch-minigame.mjs', douyin: 'launch-minigame.mjs' }[PLATFORM];+if (!LAUNCHER) {+ console.error(`verify-remote-capture: no launcher for ${PLATFORM}`);+ process.exit(2);+}+const WORK = path.join(ROOT, 'build', 'remote-capture');+const { WebSocketServer, WebSocket } = createRequire(path.join(ROOT, 'desktop', 'package.json'))('ws');++const problems = [];+const check = (ok, what) => {+ console.log(`${ok ? '✓' : '✗'} ${what}`);+ if (!ok) problems.push(what);+};++const exportPackage = (out, extra) => spawnSync(process.execPath, [+ path.join(ROOT, 'pipeline', 'bin', 'estella.mjs'), 'export', projectDir(PROJECT),+ '--platform', PLATFORM, '--out', out, ...extra,+], { encoding: 'utf8', cwd: ROOT });++const server = await createDebugChannelServer({ WebSocketServer, host: '127.0.0.1' });+let child = null;+try {+ const refused = await new Promise((resolve) => {+ const ws = new WebSocket(`ws://127.0.0.1:${server.port}/?token=not-${server.token}`);+ ws.on('unexpected-response', (_req, res) => resolve(res.statusCode));+ ws.on('open', () => { ws.close(); resolve('open'); });+ ws.on('error', () => {});+ });+ check(refused === 401, `a dial with the wrong token is refused at the upgrade (got ${refused})`);++ mkdirSync(WORK, { recursive: true });+ const shipping = exportPackage(path.join(WORK, 'shipping'), ['--minify', '--debug-channel', server.urlFor('127.0.0.1')]);+ check(shipping.status !== 0 && /never carries a debug channel/.test(`${shipping.stdout}${shipping.stderr}`),+ 'a shipping export refuses the channel');++ const out = path.join(WORK, `${PROJECT}-${PLATFORM}`);+ rmSync(out, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });+ const exported = exportPackage(out, ['--debug-channel', server.urlFor('127.0.0.1')]);+ if (exported.status !== 0) {+ console.error(`${exported.stdout}${exported.stderr}`.trim().split('\n').slice(-8).join('\n'));+ throw new Error(`export of ${PROJECT} for ${PLATFORM} failed`);+ }++ const connected = new Promise((resolve) => {+ const poll = setInterval(() => {+ const t = server.targets()[0];+ if (t) { clearInterval(poll); resolve(t); }+ }, 100);+ });+ child = spawnElectron([path.join(ROOT, 'tools', 'launchers', LAUNCHER), '--dir', out,+ '--settle', '3600', '--timeout', '60000'], { cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'] });+ let log = '';+ child.stdout.on('data', (d) => { log += d; });+ child.stderr.on('data', (d) => { log += d; });+ const exited = new Promise((resolve) => child.on('close', resolve));++ const target = await Promise.race([+ connected,+ exited.then(() => null),+ new Promise((resolve) => setTimeout(() => resolve(null), 90_000)),+ ]);+ check(!!target, `the package dialled the editor${target ? ` (${target.platform}, protocol ${target.protocol})` : ''}`);+ if (!target) {+ console.error(log.trim().split('\n').slice(-12).join('\n'));+ throw new Error('no device connected');+ }++ const report = await server.query(target.id, 'frameCapture');+ const draws = report?.draws ?? [];+ check(draws.length > 0 && report.passCount >= 1,+ `a frame came back over the socket: ${draws.length} draw(s) in ${report?.passCount ?? 0} pass(es)`);+ const named = Object.keys(report?.names ?? {}).length;+ check(named > 0, `the device named its entities (${named})`);++ const scene = draws.filter((d) => d.pass === 0);+ const last = (scene.length ? scene : draws).at(-1);+ const image = last ? await server.query(target.id, 'frameReplay', { drawIndex: last.index }) : null;+ const size = image ? image.width * image.height * 4 : 0;+ check(!!image && size > 0 && image.pixels.byteLength === size,+ `the replay of draw ${last?.index} came back as ${image?.width}x${image?.height} RGBA (${image?.pixels.byteLength ?? 0} bytes)`);+ check(!!image?.matchesCapture, 'the replay matches the frame it was captured from');+ let lit = 0;+ for (let i = 0; image && i < image.pixels.length; i += 4) {+ if (image.pixels[i + 3] > 0 && (image.pixels[i] | image.pixels[i + 1] | image.pixels[i + 2]) > 8) lit++;+ }+ check(lit > 0, `the replayed pass has drawn pixels (${lit})`);+} catch (e) {+ problems.push(e.message);+ console.error(`✗ ${e.message}`);+} finally {+ child?.kill();+ await server.close();+}++if (problems.length) {+ console.error(`\nverify-remote-capture: ${problems.length} problem(s) — ${PROJECT} on ${PLATFORM}`);+ process.exit(1);+}+console.log(`\nverify-remote-capture: ${PROJECT} on ${PLATFORM} — captured and replayed over the debug channel.`);