perf: decode-ahead sprite cache; cache bust v56

Sprites.load() now awaits img.decode() before a tier image counts as
ready, so every sprite is fully decoded during the title screen and
first-draw decode jitter disappears on weak machines. Headless smoke
keeps working via the typeof-decode fallback. Asset URLs bump to v=56.
This commit is contained in:
Quintine committed 2026-08-12 18:05:11 +10:00
1 parent 4b9e4a1e97
commit 8c2141c3f1
3 files changed
+26 -26

No files matched your search

+3 -3
View File
@@ -86,12 +86,12 @@ const Sprites = {
pending++;
const img = new Image();
const finish = () => { if (--pending === 0) G.imagesLoaded = true; };
img.onload = () => { this.imgs[name] = img; finish(); };
img.onload = () => { this.imgs[name] = img; if (typeof img.decode === 'function') img.decode().then(finish, finish); else finish(); };
img.onerror = () => {
if (hd && !img._sdRetry) { img._sdRetry = true; img.src = 'assets/' + name + '.png?v=55'; return; }
if (hd && !img._sdRetry) { img._sdRetry = true; img.src = 'assets/' + name + '.png?v=56'; return; }
finish();
};
img.src = hd ? 'assets/hd/' + name + '.webp?v=55' : 'assets/' + name + '.png?v=55';
img.src = hd ? 'assets/hd/' + name + '.webp?v=56' : 'assets/' + name + '.png?v=56';
}
},