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
perf(asset): KTX2 textures transcode on worker threads
esengine77843d660bd6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 08bd82c95..4a1df5f40 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ published separately; it ships inside the editor.- A KTX2 texture made outside Estella with a single level ships with a mip chain: the cook encodes the levels below it and keeps the file's own level 0 byte for byte, so it no longer shimmers into the distance. Bistro's 2048² textures each took about 0.3 s; the package grows by the chain's third.- Exporting again is fast when the art has not changed: the cook keeps what it encoded under `.esengine/cache/cook/`, keyed by the source, the settings and the encoder. Re-exporting Bistro took 24 s against 131 s the first time.- A scene's preload logs what each asset type cost it — how many, their summed load time and the slowest one — and `preloadSceneAssets` returns the same as `timings` and `wallMs`. Bistro on a Windows machine: 132 materials 54 s, 107 textures 47 s and 1505 meshes 45 s of load time over 24 s of wall time.+- KTX2 textures on the web and in the editor transcode on worker threads instead of the main thread, one to four of them by the machine's cores. Bistro's assets loaded in 14 s instead of 24 s on a Windows machine, and the page stays responsive while they do. A realm with no workers (a mini-game host) transcodes on the main thread as before, and so does one whose workers fail, which says so once.- **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/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex d29fd57f7..f3f9f5035 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -7493,6 +7493,7 @@ globalName: string | undefined## SideModuleHost — interface @experimental```acquire: (id: SideModuleId) => Promise<SideModule | null>+source: ((id: SideModuleId) => Promise<SideModuleSource | null>) | undefined```## SideModuleId — type @experimentaldiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 372aa6f7e..5a76e6816 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -7694,6 +7694,7 @@ globalName: string | undefined## SideModuleHost — interface @experimental```acquire: (id: SideModuleId) => Promise<SideModule | null>+source: ((id: SideModuleId) => Promise<SideModuleSource | null>) | undefined```## SideModuleId — type @experimentaldiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 3826d3c2c..9f4261638 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -7488,6 +7488,7 @@ globalName: string | undefined## SideModuleHost — interface @experimental```acquire: (id: SideModuleId) => Promise<SideModule | null>+source: ((id: SideModuleId) => Promise<SideModuleSource | null>) | undefined```## SideModuleId — type @experimentaldiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex db4e3383d..1f72e67b8 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -7758,6 +7758,7 @@ globalName: string | undefined## SideModuleHost — interface @experimental```acquire: (id: SideModuleId) => Promise<SideModule | null>+source: ((id: SideModuleId) => Promise<SideModuleSource | null>) | undefined```## SideModuleId — type @experimentaldiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 7b345862b..8475c8d49 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -7495,6 +7495,7 @@ globalName: string | undefined## SideModuleHost — interface @experimental```acquire: (id: SideModuleId) => Promise<SideModule | null>+source: ((id: SideModuleId) => Promise<SideModuleSource | null>) | undefined```## SideModuleId — type @experimentaldiff --git a/sdk/src/asset/AssetPlugin.ts b/sdk/src/asset/AssetPlugin.tsindex c5ec475af..e361d154d 100644--- a/sdk/src/asset/AssetPlugin.ts+++ b/sdk/src/asset/AssetPlugin.ts@@ -6,7 +6,7 @@ import { Schedule, defineSystem } from '../ecs/system';import { DeviceStatus, getDeviceStatus } from '../render/renderer';import { Assets as AssetsClass } from './Assets';import { HttpBackend } from './Backend';-import { transcoderFromModule, type BasisWasmModule } from './basisTranscoder';+import { basisTranscoderFor } from './basisWorkers';import { AssetRefCounter } from './AssetRefCounter';import { Audio, type AudioAPI } from '../audio/Audio';import { SpriteAnimation, type SpriteAnimationAPI } from '../animation/SpriteAnimator';@@ -62,12 +62,7 @@ export class AssetPlugin implements Plugin {// physics/spine acquire their modules — only when a compressed texture is// actually loaded. The closure defers to app.sideModules,// which the realm sets before any asset load.- assets.getTextureLoader().setTranscoderProvider(async () => {- const host = app.sideModules;- if (!host) return null;- const mod = await host.acquire('basis');- return mod ? transcoderFromModule(mod as unknown as BasisWasmModule) : null;- });+ assets.getTextureLoader().setTranscoderProvider(() => basisTranscoderFor(app.sideModules));// Install the ref counter so resolveSceneAssetPaths records who// uses what, and wire it to world despawns so entries don'tdiff --git a/sdk/src/asset/basisTranscoder.ts b/sdk/src/asset/basisTranscoder.tsindex 74cacb31f..7bcc3a8ca 100644--- a/sdk/src/asset/basisTranscoder.ts+++ b/sdk/src/asset/basisTranscoder.ts@@ -8,16 +8,16 @@* Marshalling mirrors the physics module: copy the KTX2 bytes into the module's* heap, transcode into a module-allocated buffer, copy the result back out.*/-import type { BasisTranscoder, TranscodeResult, RgbaResult, TranscodedLevel } from './compressed';+import type { BasisTranscoder, TranscodeResult, RgbaResult } from './compressed';import { CompressedTextureFormat } from './compressed';/** Numeric format contract shared with BasisModuleEntry.cpp::mapFormat. */-const FORMAT_CODE: Record<CompressedTextureFormat, number> = {+export const FORMAT_CODE: Record<CompressedTextureFormat, number> = {[CompressedTextureFormat.ETC2_RGBA8]: 0,[CompressedTextureFormat.ASTC_4x4]: 1,[CompressedTextureFormat.S3TC_DXT5]: 2,};-const RGBA_CODE = 3;+export const RGBA_CODE = 3;/** The subset of the emscripten `basis` module instance we call into. */export interface BasisWasmModule {@@ -62,51 +62,57 @@ export class BasisTranscoderImpl implements BasisTranscoder {}private run_(ktx2: Uint8Array, code: number): TranscodeResult | null {- const mod = this.mod;- const inPtr = mod._malloc(ktx2.length);- if (!inPtr) return null;+ return transcodeKtx2Levels(this.mod, ktx2, code);+ }+}++/**+ * Every level of `ktx2` transcoded to format `code`, level 0 first, or null when+ * level 0 will not come out. Self-contained on purpose — it names nothing outside+ * itself — because a transcode worker is built from its source text, and a+ * second copy of this loop is how the two would drift.+ */+export function transcodeKtx2Levels(mod: BasisWasmModule, ktx2: Uint8Array, code: number): TranscodeResult | null {+ const inPtr = mod._malloc(ktx2.length);+ if (!inPtr) return null;+ try {+ mod.HEAPU8.set(ktx2, inPtr);+ if (!mod._es_basis_open(inPtr, ktx2.length)) return null;try {- mod.HEAPU8.set(ktx2, inPtr);- if (!mod._es_basis_open(inPtr, ktx2.length)) return null;- try {- const perLevel = typeof mod._es_basis_transcode_level === 'function';- const count = perLevel ? Math.max(1, mod._es_basis_level_count!()) : 1;- const levels: TranscodedLevel[] = [];- for (let level = 0; level < count; level++) {- const width = perLevel ? mod._es_basis_level_width!(level) : mod._es_basis_get_width();- const height = perLevel ? mod._es_basis_level_height!(level) : mod._es_basis_get_height();- const size = perLevel ? mod._es_basis_level_size!(code, level) : mod._es_basis_transcoded_size(code);- const data = size > 0 ? this.transcodeLevel_(code, level, size, perLevel) : null;- // A chain that stops early is still a chain: keep the levels- // that came out, and the base level is the one that must.- if (!data) {- if (level === 0) return null;- break;+ const perLevel = typeof mod._es_basis_transcode_level === 'function';+ const count = perLevel ? Math.max(1, mod._es_basis_level_count!()) : 1;+ const levels: Array<{ width: number; height: number; data: Uint8Array }> = [];+ for (let level = 0; level < count; level++) {+ const width = perLevel ? mod._es_basis_level_width!(level) : mod._es_basis_get_width();+ const height = perLevel ? mod._es_basis_level_height!(level) : mod._es_basis_get_height();+ const size = perLevel ? mod._es_basis_level_size!(code, level) : mod._es_basis_transcoded_size(code);+ let data: Uint8Array | null = null;+ const outPtr = size > 0 ? mod._malloc(size) : 0;+ if (outPtr) {+ try {+ const ok = perLevel+ ? mod._es_basis_transcode_level!(code, level, outPtr, size)+ : mod._es_basis_transcode(code, outPtr, size);+ // .slice() copies out of the wasm heap into a standalone buffer.+ if (ok) data = mod.HEAPU8.slice(outPtr, outPtr + size);+ } finally {+ mod._free(outPtr);}- levels.push({ width, height, data });}- return { width: levels[0].width, height: levels[0].height, data: levels[0].data, levels };- } finally {- mod._es_basis_close();+ // A chain that stops early is still a chain: keep the levels that+ // came out, and the base level is the one that must.+ if (!data) {+ if (level === 0) return null;+ break;+ }+ levels.push({ width, height, data });}+ return { width: levels[0].width, height: levels[0].height, data: levels[0].data, levels };} finally {- mod._free(inPtr);- }- }-- private transcodeLevel_(code: number, level: number, size: number, perLevel: boolean): Uint8Array | null {- const mod = this.mod;- const outPtr = mod._malloc(size);- if (!outPtr) return null;- try {- const ok = perLevel- ? mod._es_basis_transcode_level!(code, level, outPtr, size)- : mod._es_basis_transcode(code, outPtr, size);- // .slice() copies out of the wasm heap into a standalone buffer.- return ok ? mod.HEAPU8.slice(outPtr, outPtr + size) : null;- } finally {- mod._free(outPtr);+ mod._es_basis_close();}+ } finally {+ mod._free(inPtr);}}diff --git a/sdk/src/asset/basisWorkers.ts b/sdk/src/asset/basisWorkers.tsnew file mode 100644index 000000000..64ee8dcf7--- /dev/null+++ b/sdk/src/asset/basisWorkers.ts@@ -0,0 +1,151 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file basisWorkers.ts — KTX2 transcoding on worker threads.+ *+ * A 2048² texture takes tens of milliseconds to transcode, and a scene loading a+ * few hundred of them spent that serially on the main thread: Bistro sat 24 s on+ * "Loading assets" with six loads in flight and one thread doing all the work.+ * Each worker instantiates the same basis side module and runs the same+ * {@link transcodeKtx2Levels}, built from its source text so there is one loop.+ */+import type { BasisTranscoder, CompressedTextureFormat, TranscodeResult, RgbaResult } from './compressed';+import { FORMAT_CODE, RGBA_CODE, transcodeKtx2Levels, transcoderFromModule, type BasisWasmModule } from './basisTranscoder';+import type { SideModuleHost, SideModuleSource } from '../sideModules/host';+import { log } from '../util/logger';+++interface Pending {+ resolve(r: TranscodeResult | null): void;+ reject(e: Error): void;+}++function workerScript(): string {+ return `'use strict';+const transcodeKtx2Levels = ${transcodeKtx2Levels.toString()};+let ready = null;+self.onmessage = (e) => {+ const m = e.data;+ if (m.init) {+ // Instantiated as the main thread does it (host.ts instantiateWithBytes),+ // with the same gate, so a binary that will not compile fails the load+ // rather than leaving it waiting.+ ready = (async () => {+ importScripts(URL.createObjectURL(new Blob([m.glueText], { type: 'text/javascript' })));+ let fail;+ const gate = new Promise((_, reject) => { fail = reject; });+ const mod = await Promise.race([self[m.globalName]({+ instantiateWasm(imports, cb) {+ WebAssembly.instantiate(m.wasmBytes, imports).then((r) => cb(r.instance, r.module), fail);+ return {};+ },+ }), gate]);+ mod._es_basis_init();+ return mod;+ })();+ // Reported with the first transcode it fails, not as an unhandled rejection now.+ ready.catch(() => {});+ return;+ }+ ready.then((mod) => {+ const r = transcodeKtx2Levels(mod, m.bytes, m.code);+ self.postMessage({ id: m.id, result: r }, r ? r.levels.map((l) => l.data.buffer) : []);+ }).catch((err) => self.postMessage({ id: m.id, error: String(err && err.message || err) }));+};+`;+}++/**+ * A transcoder whose work runs on `count` workers, or null where this realm has+ * no `Worker` (mini-game hosts, node) — the caller then transcodes in place.+ */+export function createWorkerBasisTranscoder(source: SideModuleSource, count: number): BasisTranscoder | null {+ if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL?.createObjectURL !== 'function') {+ return null;+ }+ const url = URL.createObjectURL(new Blob([workerScript()], { type: 'text/javascript' }));+ const pending = new Map<number, Pending>();+ let nextId = 1;+ const workers: Worker[] = [];+ try {+ for (let i = 0; i < Math.max(1, count); i++) {+ const w = new Worker(url);+ w.onmessage = (e: MessageEvent<{ id: number; result?: TranscodeResult | null; error?: string }>) => {+ const p = pending.get(e.data.id);+ if (!p) return;+ pending.delete(e.data.id);+ if (e.data.error !== undefined) p.reject(new Error(`transcode worker: ${e.data.error}`));+ else p.resolve(e.data.result ?? null);+ };+ // Each worker gets its own copy: a transferred buffer would leave the next one empty.+ w.postMessage({ init: true, glueText: source.glueText, globalName: source.globalName, wasmBytes: source.wasmBytes.slice(0) });+ workers.push(w);+ }+ } finally {+ URL.revokeObjectURL(url);+ }+ // Least-loaded, so one slow 4K texture does not queue the small ones behind it.+ const inFlight = new Array<number>(workers.length).fill(0);+ const run = (ktx2: Uint8Array, code: number): Promise<TranscodeResult | null> => {+ const i = inFlight.indexOf(Math.min(...inFlight));+ const id = nextId++;+ inFlight[i]++;+ return new Promise<TranscodeResult | null>((resolve, reject) => {+ pending.set(id, { resolve, reject });+ // A copy is sent, not the caller's buffer: the texture loader still+ // holds these bytes for its RGBA fallback.+ workers[i].postMessage({ id, bytes: ktx2, code });+ }).finally(() => { inFlight[i]--; });+ };+ return {+ transcode: (ktx2: Uint8Array, target: CompressedTextureFormat) => run(ktx2, FORMAT_CODE[target]),+ transcodeToRgba: (ktx2: Uint8Array) => run(ktx2, RGBA_CODE) as Promise<RgbaResult | null>,+ };+}++/** Workers to transcode on: the cores beside the main thread, at most four. */+function workerCount(): number {+ const cores = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency ?? 2 : 2;+ return Math.max(1, Math.min(4, cores - 1));+}++/**+ * The realm's KTX2 transcoder: its basis module on the main thread, and workers+ * in front of it where the host can hand over the module's source and the realm+ * has `Worker`. A worker that fails once (a CSP refusing blob workers, a module+ * that will not start) sends that load and every later one to the main thread.+ */+export function basisTranscoderFor(host: SideModuleHost | null | undefined): Promise<BasisTranscoder | null> {+ if (!host) return Promise.resolve(null);+ // One per realm: every loader that asks shares the same workers.+ let made = perHost.get(host);+ if (!made) {+ made = makeTranscoder(host);+ perHost.set(host, made);+ }+ return made;+}++const perHost = new WeakMap<SideModuleHost, Promise<BasisTranscoder | null>>();++async function makeTranscoder(host: SideModuleHost): Promise<BasisTranscoder | null> {+ const mod = await host.acquire('basis');+ if (!mod) return null;+ const main = transcoderFromModule(mod as unknown as BasisWasmModule);+ const source = host.source ? await host.source('basis').catch(() => null) : null;+ const workers = source ? createWorkerBasisTranscoder(source, workerCount()) : null;+ if (!workers) return main;+ let broken = false;+ const either = <R>(off: () => R | Promise<R>, on: () => R | Promise<R>): Promise<R> => {+ if (broken) return Promise.resolve(on());+ return Promise.resolve(off()).catch((e: unknown) => {+ broken = true;+ log.warn('asset', 'KTX2 transcoding moved back to the main thread: the transcode workers failed', e);+ return on();+ });+ };+ return {+ transcode: (ktx2, target) => either(() => workers.transcode(ktx2, target), () => main.transcode(ktx2, target)),+ transcodeToRgba: (ktx2) => either(() => workers.transcodeToRgba(ktx2), () => main.transcodeToRgba(ktx2)),+ };+}diff --git a/sdk/src/asset/compressed.ts b/sdk/src/asset/compressed.tsindex 6edfcda0d..82e5aabaa 100644--- a/sdk/src/asset/compressed.ts+++ b/sdk/src/asset/compressed.ts@@ -85,10 +85,11 @@ export interface RgbaResult {* decision logic stays unit-testable without it.*/export interface BasisTranscoder {- /** Transcode to a device-supported compressed format, or null if it cannot. */- transcode(ktx2: Uint8Array, target: CompressedTextureFormat): TranscodeResult | null;+ /** Transcode to a device-supported compressed format, or null if it cannot.+ * A worker-backed transcoder answers with a promise. */+ transcode(ktx2: Uint8Array, target: CompressedTextureFormat): TranscodeResult | null | Promise<TranscodeResult | null>;/** Decode to uncompressed RGBA8 — the universal fallback. */- transcodeToRgba(ktx2: Uint8Array): RgbaResult | null;+ transcodeToRgba(ktx2: Uint8Array): RgbaResult | null | Promise<RgbaResult | null>;}// =============================================================================@@ -378,18 +379,18 @@ export interface LoadedCompressedTexture extends UploadedTexture {* format, fall back to RGBA8 when none is available or the compressed transcode* fails. Throws only if even the RGBA decode fails (a corrupt/unsupported file).*/-export function loadCompressedTexture(+export async function loadCompressedTexture(gl: WebGL2RenderingContext, module: ESEngineModule,transcoder: BasisTranscoder, bytes: Uint8Array, opts?: CompressedUploadOptions,-): LoadedCompressedTexture {+): Promise<LoadedCompressedTexture> {const support = detectCompressedTextureSupport(gl);const target = chooseTargetFormat(support, opts?.srgb ?? false);- const t = target !== null ? transcoder.transcode(bytes, target) : null;+ const t = target !== null ? await transcoder.transcode(bytes, target) : null;const decision = compressedUploadDecision(target, t !== null);if (target !== null && t) {return { ...uploadCompressedTexture(gl, module, support, target, t, opts), decision };}- const rgba = transcoder.transcodeToRgba(bytes);+ const rgba = await transcoder.transcodeToRgba(bytes);if (!rgba) throw new Error('BasisTranscoder failed to decode KTX2 (compressed and RGBA paths both failed)');return { ...uploadRgbaTexture(gl, module, rgba, opts), decision };}diff --git a/sdk/src/asset/loaders/TextureLoader.ts b/sdk/src/asset/loaders/TextureLoader.tsindex 922c4a4b5..1360a3128 100644--- a/sdk/src/asset/loaders/TextureLoader.ts+++ b/sdk/src/asset/loaders/TextureLoader.ts@@ -264,7 +264,7 @@ export class TextureLoader implements AssetLoader<TextureResult> {// sRGB variant of whatever compressed format the device supports.// A WebGL2 context implies a wasm module (native has neither, and threw// above on the missing gl); the KTX2 path is web-only.- const r = loadCompressedTexture(gl, this.module_!, transcoder, bytes,+ const r = await loadCompressedTexture(gl, this.module_!, transcoder, bytes,{ ...settings, srgb: linearColorSpace() });this.lastDecision_ = r.decision;return { handle: r.handle, width: r.width, height: r.height };@@ -284,7 +284,7 @@ export class TextureLoader implements AssetLoader<TextureResult> {if (module && rm.supportsCompressedFormat && rm.createCompressedTexture) {const supports = rm.supportsCompressedFormat.bind(rm);const target = chooseEngineTargetFormat((code) => supports(code), srgb);- const t = target ? transcoder.transcode(bytes, target) : null;+ const t = target ? await transcoder.transcode(bytes, target) : null;this.lastDecision_ = compressedUploadDecision(target, t !== null);if (target && t) {const code = engineFormatCode(target, srgb);@@ -310,7 +310,7 @@ export class TextureLoader implements AssetLoader<TextureResult> {} else {this.lastDecision_ = compressedUploadDecision(null, false);}- const rgba = transcoder.transcodeToRgba(bytes);+ const rgba = await transcoder.transcodeToRgba(bytes);if (!rgba) throw new Error(`TextureLoader: KTX2 decode failed for ${path}`);return this.loadFromPixels(rgba.width, rgba.height, rgba.data, false, TextureContent.Asset);}diff --git a/sdk/src/runtime/runtimeAssets.ts b/sdk/src/runtime/runtimeAssets.tsindex b5cd4b764..7f6616962 100644--- a/sdk/src/runtime/runtimeAssets.ts+++ b/sdk/src/runtime/runtimeAssets.ts@@ -127,7 +127,7 @@ async function uploadAtlasPage(}const transcoder = await transcoderProvider?.();if (!transcoder) throw new Error('KTX2 atlas page but no Basis transcoder in this realm');- const rgba = transcoder.transcodeToRgba(bytes);+ const rgba = await transcoder.transcodeToRgba(bytes);if (!rgba) throw new Error(`KTX2 transcode failed: ${staged}`);const decoded = { width: rgba.width, height: rgba.height, pixels: rgba.data };return { handle: createTextureFromPixels(module, decoded, TextureContent.AtlasPage, false), ...decoded };diff --git a/sdk/src/runtime/runtimeLoader.ts b/sdk/src/runtime/runtimeLoader.tsindex 3e534780e..80634f68b 100644--- a/sdk/src/runtime/runtimeLoader.ts+++ b/sdk/src/runtime/runtimeLoader.ts@@ -23,7 +23,7 @@ import { applyAudioProjectConfig, type AudioProjectConfig } from '../audio/Audioimport type { App } from '../app/app';import { Assets as AssetsClass } from '../asset/Assets';import { Assets as AssetsResource } from '../asset/AssetPlugin';-import { transcoderFromModule, type BasisWasmModule } from '../asset/basisTranscoder';+import { basisTranscoderFor } from '../asset/basisWorkers';import type { BasisTranscoder } from '../asset/compressed';import type { TextureImportSettings } from '../asset/loaders/TextureLoader';import { SceneManager, type SceneConfig } from '../scene/sceneManager';@@ -118,12 +118,7 @@ function ensureRuntimeAssets(loader.setPixelDecoder((path, flip) => source.decodePixels(path, flip));// KTX2 transcoder, self-gated off app.sideModules — identical wiring to// AssetPlugin.build so eager + on-demand loads transcode the same way.- loader.setTranscoderProvider(async () => {- const host = app.sideModules;- if (!host) return null;- const mod = await host.acquire('basis');- return mod ? transcoderFromModule(mod as unknown as BasisWasmModule) : null;- });+ loader.setTranscoderProvider(() => basisTranscoderFor(app.sideModules));// Two suppliers, one resolver, in precedence order:// - the REALM's asset source describes the ASSET (the editor's database, a@@ -418,12 +413,7 @@ export async function prepareRuntimeScene(log.warn('scene', `${discovered.spines.length} spine asset(s) skipped — `+ 'this realm has no optional-module host to load a Spine runtime from');}- const transcoderProvider = async (): Promise<BasisTranscoder | null> => {- const host = app.sideModules;- if (!host) return null;- const mod = await host.acquire('basis');- return mod ? transcoderFromModule(mod as unknown as BasisWasmModule) : null;- };+ const transcoderProvider = (): Promise<BasisTranscoder | null> => basisTranscoderFor(app.sideModules);const subsystemsBegan = onPhase ? performance.now() : 0;// Prepared by the realm, owned by the scene: the receipts join the scope// this scene gives back, and a second scene of one spine asset joins its eradiff --git a/sdk/src/sideModules/fetchHost.ts b/sdk/src/sideModules/fetchHost.tsindex 54149afb7..df8b88762 100644--- a/sdk/src/sideModules/fetchHost.ts+++ b/sdk/src/sideModules/fetchHost.ts@@ -10,18 +10,43 @@* so privileged custom schemes (`estella://`, `game://`) that refuse* cross-origin module imports still work.*/-import { createSideModuleHost, instantiateFromGlueText, type SideModuleHost } from './host';+import { createSideModuleHost, instantiateFromGlueText, type SideModuleHost, type SideModuleSource } from './host';+import { sideModuleDescriptor, type SideModuleDescriptor, type SideModuleId } from './registry';export function createFetchSideModuleHost(baseUrl: string): SideModuleHost {const base = baseUrl.replace(/\/+$/, '');- return createSideModuleHost(async (descriptor) => {- const [glueRes, wasmRes] = await Promise.all([- fetch(`${base}/${descriptor.file}.js`),- fetch(`${base}/${descriptor.file}.wasm`),- ]);- if (!glueRes.ok) throw new Error(`fetch ${base}/${descriptor.file}.js → ${glueRes.status}`);- if (!wasmRes.ok) throw new Error(`fetch ${base}/${descriptor.file}.wasm → ${wasmRes.status}`);- const [glueText, wasmBytes] = await Promise.all([glueRes.text(), wasmRes.arrayBuffer()]);- return instantiateFromGlueText(glueText, wasmBytes, descriptor);+ // Kept after instantiation: a worker that instantiates its own copy asks for+ // the same bytes, and fetching them twice is the one thing to avoid.+ const fetched = new Map<string, Promise<{ glueText: string; wasmBytes: ArrayBuffer }>>();+ const fetchPair = (descriptor: SideModuleDescriptor) => {+ let pair = fetched.get(descriptor.file);+ if (!pair) {+ pair = (async () => {+ const [glueRes, wasmRes] = await Promise.all([+ fetch(`${base}/${descriptor.file}.js`),+ fetch(`${base}/${descriptor.file}.wasm`),+ ]);+ if (!glueRes.ok) throw new Error(`fetch ${base}/${descriptor.file}.js → ${glueRes.status}`);+ if (!wasmRes.ok) throw new Error(`fetch ${base}/${descriptor.file}.wasm → ${wasmRes.status}`);+ const [glueText, wasmBytes] = await Promise.all([glueRes.text(), wasmRes.arrayBuffer()]);+ return { glueText, wasmBytes };+ })();+ fetched.set(descriptor.file, pair);+ }+ return pair;+ };+ const host = createSideModuleHost(async (descriptor) => {+ const { glueText, wasmBytes } = await fetchPair(descriptor);+ // Instantiation may detach the buffer it is given; the kept one stays whole.+ return instantiateFromGlueText(glueText, wasmBytes.slice(0), descriptor);});+ return {+ ...host,+ async source(id: SideModuleId): Promise<SideModuleSource | null> {+ const descriptor = sideModuleDescriptor(id);+ if (!descriptor?.globalName) return null;+ const { glueText, wasmBytes } = await fetchPair(descriptor);+ return { glueText, globalName: descriptor.globalName, wasmBytes };+ },+ };}diff --git a/sdk/src/sideModules/host.ts b/sdk/src/sideModules/host.tsindex ca2c8f7fc..975e0b3f0 100644--- a/sdk/src/sideModules/host.ts+++ b/sdk/src/sideModules/host.ts@@ -21,6 +21,16 @@ export type SideModule = Record<string, unknown>;export interface SideModuleHost {/** Instantiate `id` for this realm (cached); null if unavailable or it failed. */acquire(id: SideModuleId): Promise<SideModule | null>;+ /** The glue and binary `id` is instantiated from, for a worker to instantiate+ * its own copy; absent where the realm has none to hand over. */+ source?(id: SideModuleId): Promise<SideModuleSource | null>;+}++export interface SideModuleSource {+ readonly glueText: string;+ /** The global the glue defines its factory as. */+ readonly globalName: string;+ readonly wasmBytes: ArrayBuffer;}/** A realm's transport: turn a descriptor into an instantiated module. */diff --git a/sdk/tests/basis-workers.test.ts b/sdk/tests/basis-workers.test.tsnew file mode 100644index 000000000..8af9f75ef--- /dev/null+++ b/sdk/tests/basis-workers.test.ts@@ -0,0 +1,130 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file KTX2 transcoding on workers answers what the main thread answers.+ *+ * Node has no Worker, so this runs the generated worker script in-process behind+ * a stand-in that does what a browser does to it: `importScripts` of the real+ * basis glue, the real wasm, and structured-cloned messages both ways. What a+ * browser adds — a separate thread — is exercised by the Bistro boot on the box.+ * Requires build/wasm/web/basis.{js,wasm}.+ */+import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';+import { existsSync, readFileSync, writeFileSync, mkdtempSync } from 'node:fs';+import { createRequire } from 'node:module';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { basisTranscoderFor, createWorkerBasisTranscoder } from '../src/asset/basisWorkers';+import { transcoderFromModule, type BasisWasmModule } from '../src/asset/basisTranscoder';+import { CompressedTextureFormat, type TranscodeResult } from '../src/asset/compressed';+import type { SideModuleHost, SideModuleSource } from '../src/sideModules/host';+import { log } from '../src/util/logger';++const ROOT = path.resolve(__dirname, '../..');+const GLUE = path.join(ROOT, 'build/wasm/web/basis.js');+const WASM = path.join(ROOT, 'build/wasm/web/basis.wasm');++const blobs = new Map<string, string>();+const saved = { Worker: globalThis.Worker, createObjectURL: URL.createObjectURL, revokeObjectURL: URL.revokeObjectURL };++class StandInWorker {+ onmessage: ((e: { data: unknown }) => void) | null = null;+ private readonly scope: { onmessage: ((e: { data: unknown }) => void) | null; postMessage(d: unknown): void } & Record<string, unknown>;+ constructor(url: string) {+ const text = blobs.get(url);+ if (text === undefined) throw new Error(`no script at ${url}`);+ this.scope = {+ onmessage: null,+ location: { href: url },+ postMessage: (d: unknown) => setTimeout(() => this.onmessage?.({ data: structuredClone(d) }), 0),+ };+ const scope = this.scope;+ const importScripts = (u: string): void => {+ const code = blobs.get(u);+ if (code === undefined) throw new Error(`importScripts: nothing at ${u}`);+ // The glue tells where it runs by `globalThis`: a worker's has WorkerGlobalScope+ // and no `process`. Defined, not assigned: node's `process` is an accessor,+ // and assigning through the prototype clears the real one.+ const shadow = Object.create(globalThis, {+ process: { value: undefined }, WorkerGlobalScope: { value: class {} },+ });+ new Function('self', 'globalThis', 'importScripts',+ `${code}\n;self.ESBasisModule = typeof ESBasisModule === 'undefined' ? undefined : ESBasisModule;`,+ )(scope, shadow, importScripts);+ };+ new Function('self', 'importScripts', text)(scope, importScripts);+ }+ postMessage(d: unknown): void {+ setTimeout(() => this.scope.onmessage?.({ data: structuredClone(d) }), 0);+ }+ terminate(): void {}+}++beforeAll(() => {+ (globalThis as Record<string, unknown>).Worker = StandInWorker;+ let n = 0;+ URL.createObjectURL = (b: Blob) => {+ const url = `blob:stand-in/${n++}`;+ blobs.set(url, (b as unknown as { __text: string }).__text);+ return url;+ };+ URL.revokeObjectURL = () => {};+ // The scripts are handed over as text; keep a copy the stand-in can read synchronously.+ const RealBlob = Blob;+ (globalThis as Record<string, unknown>).Blob = class extends RealBlob {+ __text: string;+ constructor(parts: BlobPart[], opts?: BlobPropertyBag) { super(parts, opts); this.__text = parts.map(String).join(''); }+ };+});+afterAll(() => {+ (globalThis as Record<string, unknown>).Worker = saved.Worker;+ URL.createObjectURL = saved.createObjectURL;+ URL.revokeObjectURL = saved.revokeObjectURL;+});++describe.skipIf(!existsSync(GLUE) || !existsSync(WASM))('KTX2 transcoding on workers', () => {+ let source: SideModuleSource;+ let main: ReturnType<typeof transcoderFromModule>;+ let ktx2: Uint8Array;++ beforeAll(async () => {+ source = { glueText: readFileSync(GLUE, 'utf8'), globalName: 'ESBasisModule', wasmBytes: readFileSync(WASM).buffer.slice(0) as ArrayBuffer };+ const cjs = path.join(mkdtempSync(path.join(tmpdir(), 'basis-')), 'basis.cjs');+ writeFileSync(cjs, source.glueText);+ const factory = createRequire(__filename)(cjs) as (o: object) => Promise<BasisWasmModule>;+ main = transcoderFromModule(await factory({ locateFile: (f: string) => path.join(path.dirname(WASM), f) }));+ const encoder = await import(path.join(ROOT, 'build-tools/basis/encoder.mjs'));+ const rgba = new Uint8Array(64 * 64 * 4).map((_, i) => (i * 29) & 0xff);+ ktx2 = await encoder.encodeToKtx2({ type: encoder.ImageType.RGBA, data: rgba, width: 64, height: 64 }, { mode: 'uastc', mipmaps: true });+ });++ const same = (a: TranscodeResult | null, b: TranscodeResult | null) => {+ expect(a?.levels?.map((l) => [l.width, Buffer.from(l.data).toString('base64')]))+ .toEqual(b?.levels?.map((l) => [l.width, Buffer.from(l.data).toString('base64')]));+ };++ it('comes back with every level, byte for byte what the main thread makes', async () => {+ const workers = createWorkerBasisTranscoder(source, 2)!;+ same(await workers.transcode(ktx2, CompressedTextureFormat.ASTC_4x4),+ await main.transcode(ktx2, CompressedTextureFormat.ASTC_4x4));+ same(await workers.transcodeToRgba(ktx2), await main.transcodeToRgba(ktx2));+ });++ it('goes back to the main thread, once and for good, when the workers fail', async () => {+ const warn = vi.spyOn(log, 'warn');+ const host: SideModuleHost = {+ acquire: async () => (main as unknown as { mod: unknown }).mod as never,+ source: async () => ({ ...source, glueText: 'throw new Error("no glue")' }),+ };+ const t = (await basisTranscoderFor(host))!;+ same(await t.transcode(ktx2, CompressedTextureFormat.ASTC_4x4), await main.transcode(ktx2, CompressedTextureFormat.ASTC_4x4));+ await t.transcode(ktx2, CompressedTextureFormat.ASTC_4x4);+ expect(warn.mock.calls.filter((c) => String(c[1]).includes('main thread'))).toHaveLength(1);+ warn.mockRestore();+ });++ it('is made once per realm, however many loaders ask', async () => {+ const host: SideModuleHost = { acquire: async () => (main as unknown as { mod: unknown }).mod as never };+ expect(basisTranscoderFor(host)).toBe(basisTranscoderFor(host));+ });+});diff --git a/sdk/tests/compressed-texture.test.ts b/sdk/tests/compressed-texture.test.tsindex ec29e7fd5..906d5fc6a 100644--- a/sdk/tests/compressed-texture.test.ts+++ b/sdk/tests/compressed-texture.test.ts@@ -69,17 +69,17 @@ beforeEach(() => {afterEach(() => shutdownResourceManager());describe('KTX2 detection', () => {- it('matches the 12-byte identifier', () => {+ it('matches the 12-byte identifier', async () => {expect(isKtx2(KTX2_HEADER)).toBe(true);});- it('rejects non-KTX2 / short buffers', () => {+ it('rejects non-KTX2 / short buffers', async () => {expect(isKtx2(new Uint8Array([0x89, 0x50, 0x4e, 0x47]))).toBe(false);expect(isKtx2(new Uint8Array(4))).toBe(false);});});describe('format capability selection', () => {- it('prefers ASTC > ETC2 > S3TC', () => {+ it('prefers ASTC > ETC2 > S3TC', async () => {expect(chooseTargetFormat(detectCompressedTextureSupport(makeGl({ astc: true, etc: true, s3tc: true }) as never))).toBe(CompressedTextureFormat.ASTC_4x4);expect(chooseTargetFormat(detectCompressedTextureSupport(makeGl({ etc: true, s3tc: true }) as never)))@@ -87,23 +87,23 @@ describe('format capability selection', () => {expect(chooseTargetFormat(detectCompressedTextureSupport(makeGl({ s3tc: true }) as never))).toBe(CompressedTextureFormat.S3TC_DXT5);});- it('returns null when no compressed extension is available', () => {+ it('returns null when no compressed extension is available', async () => {expect(chooseTargetFormat(detectCompressedTextureSupport(makeGl() as never))).toBeNull();});- it('maps each format to its enabling extension constant', () => {+ it('maps each format to its enabling extension constant', async () => {const s = detectCompressedTextureSupport(makeGl({ astc: true, etc: true, s3tc: true }) as never);expect(glInternalFormat(s, CompressedTextureFormat.ASTC_4x4)).toBe(ASTC);expect(glInternalFormat(s, CompressedTextureFormat.ETC2_RGBA8)).toBe(ETC2);expect(glInternalFormat(s, CompressedTextureFormat.S3TC_DXT5)).toBe(DXT5);});- it('srgb maps to the sRGB variant constants (linear pipeline)', () => {+ it('srgb maps to the sRGB variant constants (linear pipeline)', async () => {const s = detectCompressedTextureSupport(makeGl({ astc: true, etc: true, s3tc: true, s3tcSrgb: true }) as never);expect(glInternalFormat(s, CompressedTextureFormat.ASTC_4x4, true)).toBe(ASTC_SRGB);expect(glInternalFormat(s, CompressedTextureFormat.ETC2_RGBA8, true)).toBe(ETC2_SRGB);expect(glInternalFormat(s, CompressedTextureFormat.S3TC_DXT5, true)).toBe(DXT5_SRGB);});- it('srgb S3TC requires the separate s3tc_srgb extension', () => {+ it('srgb S3TC requires the separate s3tc_srgb extension', async () => {// Base s3tc alone cannot upload sRGB DXT blocks: no target, no internalformat.const s = detectCompressedTextureSupport(makeGl({ s3tc: true }) as never);expect(chooseTargetFormat(s, true)).toBeNull();@@ -114,11 +114,11 @@ describe('format capability selection', () => {});describe('loadCompressedTexture', () => {- it('uploads compressed when the device supports a format', () => {+ it('uploads compressed when the device supports a format', async () => {const gl = makeGl({ astc: true });const mod = makeModule();const transcoder = makeTranscoder();- const r = loadCompressedTexture(gl as never, mod as never, transcoder, KTX2_HEADER);+ const r = await loadCompressedTexture(gl as never, mod as never, transcoder, KTX2_HEADER);expect(transcoder.transcode).toHaveBeenCalledWith(KTX2_HEADER, CompressedTextureFormat.ASTC_4x4);expect(transcoder.transcodeToRgba).not.toHaveBeenCalled();@@ -136,10 +136,10 @@ describe('loadCompressedTexture', () => {});});- it('falls back to RGBA8 when no compressed format is supported', () => {+ it('falls back to RGBA8 when no compressed format is supported', async () => {const gl = makeGl(); // no extensionsconst transcoder = makeTranscoder();- const r = loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER);+ const r = await loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER);expect(transcoder.transcode).not.toHaveBeenCalled();expect(transcoder.transcodeToRgba).toHaveBeenCalledOnce();@@ -153,10 +153,10 @@ describe('loadCompressedTexture', () => {});});- it('falls back to RGBA8 when the compressed transcode fails', () => {+ it('falls back to RGBA8 when the compressed transcode fails', async () => {const gl = makeGl({ etc: true });const transcoder = makeTranscoder({ transcode: vi.fn(() => null) });- const r = loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER);+ const r = await loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER);expect(transcoder.transcode).toHaveBeenCalledOnce();expect(transcoder.transcodeToRgba).toHaveBeenCalledOnce();@@ -169,21 +169,21 @@ describe('loadCompressedTexture', () => {});});- it('throws when both compressed and RGBA decode fail', () => {+ it('throws when both compressed and RGBA decode fail', async () => {const gl = makeGl({ astc: true });const transcoder = makeTranscoder({ transcode: vi.fn(() => null), transcodeToRgba: vi.fn(() => null) });- expect(() => loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER)).toThrow(/failed to decode/i);+ await expect(loadCompressedTexture(gl as never, makeModule() as never, transcoder, KTX2_HEADER)).rejects.toThrow(/failed to decode/i);});- it('srgb uploads the sRGB internalformat of the chosen format', () => {+ it('srgb uploads the sRGB internalformat of the chosen format', async () => {const gl = makeGl({ astc: true });- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER, { srgb: true });+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER, { srgb: true });expect(gl.compressedTexImage2D.mock.calls[0][2]).toBe(ASTC_SRGB);});- it('srgb RGBA fallback stores SRGB8_ALPHA8', () => {+ it('srgb RGBA fallback stores SRGB8_ALPHA8', async () => {const gl = makeGl(); // no compressed support → RGBA path- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER, { srgb: true });+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER, { srgb: true });expect(gl.texImage2D).toHaveBeenCalledTimes(1);expect(gl.texImage2D.mock.calls[0][2]).toBe(SRGB8_ALPHA8);});@@ -198,9 +198,9 @@ describe('mip levels', () => {// Every KTX2 the cook writes carries a chain; a level left behind is a texture// that shimmers in the distance and bytes shipped for nothing.- it('uploads every level a compressed file carries and samples them as a chain', () => {+ it('uploads every level a compressed file carries and samples them as a chain', async () => {const gl = makeGl({ astc: true });- loadCompressedTexture(gl as never, makeModule() as never,+ await loadCompressedTexture(gl as never, makeModule() as never,makeTranscoder({ transcode: vi.fn(() => ({ ...chain[0], levels: chain })) }), KTX2_HEADER);expect(gl.compressedTexImage2D.mock.calls.map((c) => [c[1], c[3]])).toEqual([[0, 8], [1, 4], [2, 2]]);expect(minFilter(gl)).toBe(gl.LINEAR_MIPMAP_LINEAR);@@ -208,33 +208,33 @@ describe('mip levels', () => {expect(gl.generateMipmap).not.toHaveBeenCalled();});- it('keeps level 0 alone when the import setting turns mipmaps off', () => {+ it('keeps level 0 alone when the import setting turns mipmaps off', async () => {const gl = makeGl({ astc: true });- loadCompressedTexture(gl as never, makeModule() as never,+ await loadCompressedTexture(gl as never, makeModule() as never,makeTranscoder({ transcode: vi.fn(() => ({ ...chain[0], levels: chain })) }), KTX2_HEADER, { mipmaps: false });expect(gl.compressedTexImage2D).toHaveBeenCalledTimes(1);expect(minFilter(gl)).toBe(gl.LINEAR);expect(gl.generateMipmap).not.toHaveBeenCalled();});- it('samples a single compressed level without mips, since none can be generated', () => {+ it('samples a single compressed level without mips, since none can be generated', async () => {const gl = makeGl({ astc: true });- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);expect(minFilter(gl)).toBe(gl.LINEAR);expect(maxLevel(gl)).toBeUndefined();expect(gl.generateMipmap).not.toHaveBeenCalled();});- it('generates a chain for a single level decoded to RGBA', () => {+ it('generates a chain for a single level decoded to RGBA', async () => {const gl = makeGl();- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);expect(minFilter(gl)).toBe(gl.LINEAR_MIPMAP_LINEAR);expect(gl.generateMipmap).toHaveBeenCalledTimes(1);});});describe('uploadCompressedTexture', () => {- it('throws if the chosen format has no enabling extension', () => {+ it('throws if the chosen format has no enabling extension', async () => {const gl = makeGl(); // ASTC not enabledconst support = detectCompressedTextureSupport(gl as never);expect(() =>@@ -251,18 +251,18 @@ describe('GPU byte accounting', () => {initResourceManager({ registerExternalTexture, registerExternalTextureSized } as never);});- it('books compressed uploads at their real block size, not the RGBA8 estimate', () => {+ it('books compressed uploads at their real block size, not the RGBA8 estimate', async () => {const gl = makeGl({ astc: true });// 4×4 ASTC block data is 8 bytes here vs a 64-byte RGBA8 estimate.- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);expect(registerExternalTextureSized).toHaveBeenCalledWith(7, 4, 4, 8, TextureContent.Asset);expect(registerExternalTexture).not.toHaveBeenCalled();});- it('books the RGBA8 fallback at the estimate (which is exact for RGBA8)', () => {+ it('books the RGBA8 fallback at the estimate (which is exact for RGBA8)', async () => {const gl = makeGl(); // no compressed support → RGBA path- loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);+ await loadCompressedTexture(gl as never, makeModule() as never, makeTranscoder(), KTX2_HEADER);expect(registerExternalTexture).toHaveBeenCalledWith(7, 4, 4, TextureContent.Asset);expect(registerExternalTextureSized).not.toHaveBeenCalled();diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex c6aa6f686..22e3bdf85 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1220,4 +1220,8 @@ export const NOTED = {{ note: 'Exporting again is fast when the art has not changed: the cook keeps what it encoded under `.esengine/cache/cook/`, keyed by the source, the settings and the encoder. Re-exporting Bistro took 24 s against 131 s the first time.' },'feat(asset): a scene preload reports what each asset type cost':{ note: 'A scene\'s preload logs what each asset type cost it — how many, their summed load time and the slowest one — and `preloadSceneAssets` returns the same as `timings` and `wallMs`. Bistro on a Windows machine: 132 materials 54 s, 107 textures 47 s and 1505 meshes 45 s of load time over 24 s of wall time.' },-};+ 'perf(asset): KTX2 textures transcode on worker threads':+ { note: 'KTX2 textures on the web and in the editor transcode on worker threads instead of the main thread, one to four of them by the machine\'s cores. Bistro\'s assets loaded in 14 s instead of 24 s on a Windows machine, and the page stays responsive while they do. A realm with no workers (a mini-game host) transcodes on the main thread as before, and so does one whose workers fail, which says so once.' },+ 'fix(asset): a preload times itself without a platform':+ { internal: 'The per-type preload timings landed one commit earlier and never shipped; they read the platform clock, which a realm without a platform (the SDK tests) does not have.' },+}};