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 hot update that rebinds nothing now says so

yhh2c9fd98ab021
diff --git a/sdk/src/asset/Assets.ts b/sdk/src/asset/Assets.ts
index 71bb83d1a..337d5aede 100644
--- a/sdk/src/asset/Assets.ts
+++ b/sdk/src/asset/Assets.ts
@@ -967,6 +967,13 @@ export class Assets {
this.setManifest(pending.model);
// The manifest record already says what kind each changed asset is; the
// notification carries it rather than collapsing to "maybe a texture".
+ // Changing content and rebinding nothing had no words: every holder keeps
+ // the old pixels while the caller is told `applied: true, failed: 0`. With
+ // the keys, because a key the cache never saw is what that looks like.
+ if (changed.length > 0 && oldHandles.size === 0) {
+ log.warn('asset', `applyUpdate: ${changed.length} asset(s) changed and none was bound to a live texture`
+ + ` — nothing will rebind. keys: ${changed.map((c) => `${c.key} (${c.type})`).join(', ')}`);
+ }
for (const c of changed) this.fireInvalidate_({ ref: c.key, type: c.type, oldValue: oldHandles.get(c.key) });
// A changed asset is content-addressed, so its next load finds the update
// on its own. An era already BUILT from one cannot: it holds what it read
diff --git a/sdk/src/hotUpdateRebind.ts b/sdk/src/hotUpdateRebind.ts
index db4477611..bf3a2dcd6 100644
--- a/sdk/src/hotUpdateRebind.ts
+++ b/sdk/src/hotUpdateRebind.ts
@@ -101,7 +101,12 @@ export function installHotUpdateRebind(app: App, assets: Assets): LiveBindingsDa
// `ready` a frame or two later, each with the scope it is for.
while (pending.length > 0) {
const { ref, type, oldValue } = pending.shift()!;
+ // Nobody holding it is the other silent end: the update committed,
+ // the pixels did not move, nothing said why. Usually two cache
+ // entries for one image, under two spellings of the same asset.
+ let owners = 0;
for (const scope of ownerScopesOf(world, type, oldValue, ownerScopeOf)) {
+ owners++;
reloading++;
void acquire(assets, type, ref).then(
(lease) => { ready.push({ type, oldValue, scope, lease }); },
@@ -110,6 +115,10 @@ export function installHotUpdateRebind(app: App, assets: Assets): LiveBindingsDa
},
).finally(() => { reloading--; });
}
+ if (owners === 0) {
+ log.warn('asset', `hot-update rebind: nothing holds "${ref}" (${type}) at ${String(oldValue)}`
+ + ' — the update landed and no live binding moved');
+ }
}
while (ready.length > 0) {
const { type, oldValue, scope, lease } = ready.shift()!;
diff --git a/tools/launchers/headless-hotupdate-verify.mjs b/tools/launchers/headless-hotupdate-verify.mjs
index e53ec3d69..2912b6c38 100644
--- a/tools/launchers/headless-hotupdate-verify.mjs
+++ b/tools/launchers/headless-hotupdate-verify.mjs
@@ -95,7 +95,7 @@ function serve(buildDir, cdnDir, broken) {
app.whenReady().then(async () => {
let server;
const diag = [];
- let before = null, after = null, changed = 0;
+ let before = null, after = null, changed = 0, good = null;
let failed = true;
const refused = [];
try {
@@ -119,6 +119,10 @@ app.whenReady().then(async () => {
before = await exec(center);
const upd = await exec(`window.__estellaCooked.applyRemoteUpdate(${JSON.stringify(`${base}/cdn/asset-manifest.json`)}, ${JSON.stringify(`${base}/cdn`)})`);
+ // The WHOLE verdict, not just the count. Reporting `changed` alone made a
+ // refused update and an applied-but-unrebound one read identically — the
+ // pixel is green either way, and which of the two it is is the diagnosis.
+ good = upd ?? null;
changed = upd && typeof upd.changed === 'number' ? upd.changed : 0;
await sleep(1800);
after = await exec(center);
@@ -147,7 +151,7 @@ app.whenReady().then(async () => {
const ok = isGreen(before) && isRed(after) && changed >= 1 && refused.every((r) => r.ok);
console.log(`\n[verify:render:hotupdate] ${ok ? 'PASS' : 'FAIL'}`);
- console.log('DRIVE_RESULT ' + JSON.stringify({ before, after, changed, greenBefore: isGreen(before), redAfter: isRed(after), refused, diag: diag.slice(0, 8) }));
+ console.log('DRIVE_RESULT ' + JSON.stringify({ before, after, changed, good, greenBefore: isGreen(before), redAfter: isRed(after), refused, diag: diag.slice(0, 8) }));
failed = !ok;
} catch (e) {
console.log('\n[verify:render:hotupdate] FAIL — ' + (e?.message ?? e));