mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
46ad53aa35
commit
ffbd9fe4c2
2 files changed
+22
-1
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user