Weather: an empty frame tile whose encode failed is encoded again

The shared transparent tile kept a rejected encode, so every later empty
tile failed with it. A failed encode is now dropped and the next empty tile
tries again.
This commit is contained in:
Sameh Khamis committed 2026-11-11 14:29:35 -08:00
1 parent 46ad53aa35
commit ffbd9fe4c2
2 files changed
+22 -1

No files matched your search

+5 -1
View File
@@ -86,7 +86,11 @@ export function createFrameTileFetch({
});
if (pixels === null) {
both?.throwIfAborted();
empty ??= canvasBytes(canvas());
// A failed encode is not kept: the next empty tile tries again.
empty ??= canvasBytes(canvas()).catch((error) => {
empty = null;
throw error;
});
return { bytes: (await empty).slice(0), contentType: 'image/png' };
}
let tileCanvas;
+17
View File
@@ -198,6 +198,23 @@ test('a null tile is one shared transparent tile, drawn rather than missing', as
assert.equal(canvases[0].encoded, 1);
});
test('an empty tile that failed to encode is encoded again next time', async () => {
const { ask, canvases } = frameFetch(async () => null, {
createCanvas: () => {
const canvas = tileCanvas();
if (!canvases.length)
canvas.convertToBlob = async () =>
Promise.reject(new Error('no encoder'));
canvases.push(canvas);
return canvas;
},
});
await assert.rejects(ask(0, 0, 0), /no encoder/);
const next = await ask(1, 0, 0);
assert.equal(text(next.bytes), 'tile:0');
assert.equal(canvases.length, 2);
});
test('a failed tile rejects, which the renderer reports as a tile error', async () => {
const { ask } = frameFetch(async () => {
throw new Error('frame unavailable');