Skip to content

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.

fix(assets): a load that failed is warned, not only recorded

esengine7573060949e7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b963362f..9e993661f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,15 @@ published separately; it ships inside the editor.
## [Unreleased]
+### Fixed
+
+- **An asset that fails to load says so.** A reference pointing at nothing already warned,
+ but an asset whose load actually threw was recorded silently: the scene opened with no
+ texture, no environment and no complaint anywhere, which looks exactly like a scene that
+ has none. A report from a 0.69.0 user showed the shape of it — a 3D template open for six
+ minutes with zero textures loaded, zero render targets and not one warning in the whole
+ diagnostic bundle. The failures are now warned once, with what failed and why.
+
### Added
- **A WeChat mini-game can ship its engine compressed, freeing a third of the main
diff --git a/sdk/src/asset/Assets.ts b/sdk/src/asset/Assets.ts
index c4b34194d..6fe27dd5c 100644
--- a/sdk/src/asset/Assets.ts
+++ b/sdk/src/asset/Assets.ts
@@ -1419,6 +1419,14 @@ export class Assets {
onProgress?.(++loadedCount, totalCount);
});
+ // `unresolved` refs warn above; a load that THREW only reached `missing`,
+ // which callers may ignore — so a scene drew with no textures and no
+ // complaint, indistinguishable from a scene that has none.
+ const failed = missing.filter((m) => m.reason === 'load-failed');
+ if (failed.length > 0) {
+ log.warn('asset', `${failed.length} asset(s) failed to load`, failed);
+ }
+
return { textureHandles, materialHandles, fontHandles, meshHandles, environmentHandles,
probeVolumeHandles, releaseCallbacks, scope, missing };
}
diff --git a/sdk/tests/asset-missing.test.ts b/sdk/tests/asset-missing.test.ts
index 044c18bab..5c8e6c842 100644
--- a/sdk/tests/asset-missing.test.ts
+++ b/sdk/tests/asset-missing.test.ts
@@ -113,3 +113,34 @@ describe('MissingAssetsError', () => {
expect(err.message).toMatch(/1 asset/);
});
});
+
+
+describe('a load that failed says so', () => {
+ // An `unresolved` ref warns; a load that THREW only reached `missing`, which
+ // the editor's caller ignores — leaving a scene with no textures and no
+ // complaint, indistinguishable from a scene that has none.
+ it('warns when an asset fails to load, not only when a ref is unresolved', async () => {
+ const { Assets } = await import('../src/asset/Assets');
+ const { log } = await import('../src/util/logger');
+ const warn = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ try {
+ const assets = Assets.create({
+ backend: {
+ resolveUrl: (p: string) => p,
+ fetchText: async () => { throw new Error('disk went away'); },
+ fetchBinary: async () => { throw new Error('disk went away'); },
+ } as never,
+ module: { _malloc: () => 0, _free: () => {} } as never,
+ });
+ const res = await assets.preloadSceneAssets(scene('assets/ok.png'));
+
+ const failed = res.missing.filter((m: { reason: string }) => m.reason === 'load-failed');
+ expect(failed.length).toBeGreaterThan(0);
+ const said = warn.mock.calls.some(([scope, msg]) =>
+ scope === 'asset' && String(msg).includes('failed to load'));
+ expect(said, `a failed load was recorded but never logged: ${JSON.stringify(res.missing)}`).toBe(true);
+ } finally {
+ warn.mockRestore();
+ }
+ });
+});
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 4ff461859..9f7225d4a 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,9 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'fix(assets): a load that failed is warned, not only recorded':
+ { note: 'An asset that fails to load says so.' },
+
'feat(export): the engine binary can ship as .wasm.br to a host that takes one':
{ note: 'A WeChat mini-game can ship its engine compressed, freeing a third of the main' },