From 28a00e0f33b9384833c34dc35079551168d12d0a Mon Sep 17 00:00:00 2001 From: sganggs Date: Sun, 4 Oct 2026 17:43:32 +0800 Subject: [PATCH] feedback3 WD: a fresh model load also forgets PIXI's pending requests keyed by the absolute URL of the same path (GitHub #68) --- public/js/assets.js | 5 +++-- test/render/feedback3-stuck-load.test.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/assets.js b/public/js/assets.js index 03c7c0f8..44dc1dfd 100644 --- a/public/js/assets.js +++ b/public/js/assets.js @@ -573,9 +573,10 @@ export function forgetPendingSpine(entry, keep) { const done = (u) => { try { return !!PIXI.Assets.cache?.has?.(u); } catch { return true; } }; if (done(skel)) return 0; const atlas = (typeof entry.atlas === 'string' && entry.atlas) || skel.replace(/\.skel$/, '.atlas'); - const urls = done(atlas) ? [skel] : [skel, atlas, ...spinePages(entry)]; + const urls = (done(atlas) ? [skel] : [skel, atlas, ...spinePages(entry)]).filter((u) => !(keep && keep.has(u))); let n = 0; - for (const u of urls) if (!(keep && keep.has(u)) && Object.hasOwn(cache, u)) { delete cache[u]; n++; } + // the loader keys its cache by the resolved URL: the manifest path itself, or that path made absolute + for (const key of Object.keys(cache)) if (urls.some((u) => key === u || (u.startsWith('/') && key.endsWith(u)))) { delete cache[key]; n++; } return n; } diff --git a/test/render/feedback3-stuck-load.test.js b/test/render/feedback3-stuck-load.test.js index 397c3851..deece1b0 100644 --- a/test/render/feedback3-stuck-load.test.js +++ b/test/render/feedback3-stuck-load.test.js @@ -77,6 +77,9 @@ test('forgetPendingSpine: PIXI\'s pending requests of an unfinished skeleton go, c = setup([]); forgetPendingSpine(e, new Set([page])); assert.ok(c[page], 'a page another cached skeleton uses stays'); + c = setup([]); + c[`http://127.0.0.1:8080${e.atlas}`] = {}; + assert.equal(forgetPendingSpine(e), 4, 'an absolute key of the same path too'); globalThis.PIXI = {}; assert.equal(forgetPendingSpine(e), 0, 'no loader cache: nothing'); } finally { globalThis.PIXI = prev; }