mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Cesium imageryFrames: frames waiting on a tile video let go fail
An evicted (or cleared) tile video is emptied, so it never loads or seeks again, and every frame queued on it waited forever, leaving its tiles never finished. Letting a video go now fails what waits on it, and a seek that does not end within 10 s fails its frame.
This commit is contained in:
1 parent
9d3e99c831
commit
a3ffb33563
3 files changed
+122
-22
No files matched your search
@@ -1,11 +1,13 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import test from 'node:test';
|
||||
import test, { mock } from 'node:test';
|
||||
import {
|
||||
createTileVideos,
|
||||
framesOf,
|
||||
heldFrames,
|
||||
layerDrawn,
|
||||
shownAt,
|
||||
VIDEO_SEEK_TIMEOUT_MS,
|
||||
VIDEO_STEP_MS,
|
||||
videoProvider,
|
||||
} from './imageryFrames.js';
|
||||
@@ -156,3 +158,70 @@ test('a layer is drawn once every tile drawn shows its own imagery', () => {
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
/** A page whose videos load (or never do) as the test says. */
|
||||
function fakeVideoPage() {
|
||||
const made = [];
|
||||
const original = globalThis.document;
|
||||
globalThis.document = {
|
||||
createElement(tag) {
|
||||
if (tag === 'canvas') return { getContext: () => ({ drawImage() {} }) };
|
||||
const target = new EventTarget();
|
||||
const video = Object.assign(target, {
|
||||
duration: NaN,
|
||||
currentTime: 0,
|
||||
seeking: false,
|
||||
videoWidth: 2,
|
||||
videoHeight: 2,
|
||||
src: '',
|
||||
removeAttribute(name) {
|
||||
if (name === 'src') video.src = '';
|
||||
},
|
||||
load() {},
|
||||
});
|
||||
made.push(video);
|
||||
return video;
|
||||
},
|
||||
};
|
||||
return { made, restore: () => (globalThis.document = original) };
|
||||
}
|
||||
|
||||
test('frames waiting on a tile video that is let go fail, never wait forever', async () => {
|
||||
const { made, restore } = fakeVideoPage();
|
||||
try {
|
||||
const videos = createTileVideos(1);
|
||||
// Never loads.
|
||||
const first = videos.frame('a.webm', 0);
|
||||
const queued = videos.frame('a.webm', 0.5);
|
||||
// A second video past the limit lets the first go.
|
||||
const other = videos.frame('b.webm', 0);
|
||||
assert.equal(made[0].src, '', 'the first is emptied');
|
||||
await assert.rejects(first, /let go/);
|
||||
await assert.rejects(queued, /let go/);
|
||||
videos.clear();
|
||||
await assert.rejects(other, /let go/);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a tile video seek that never ends fails its frame after the seek timeout', async () => {
|
||||
const { made, restore } = fakeVideoPage();
|
||||
mock.timers.enable({ apis: ['setTimeout'] });
|
||||
try {
|
||||
const videos = createTileVideos(4);
|
||||
const frame = videos.frame('a.webm', 0.5);
|
||||
made[0].duration = 10;
|
||||
made[0].dispatchEvent(new Event('loadeddata'));
|
||||
// Let the load settle and the seek start; it never sends `seeked`.
|
||||
for (let i = 0; i < 5; i++) await Promise.resolve();
|
||||
let failed = null;
|
||||
frame.catch((error) => (failed = error));
|
||||
mock.timers.tick(VIDEO_SEEK_TIMEOUT_MS);
|
||||
for (let i = 0; i < 5; i++) await Promise.resolve();
|
||||
assert.match(String(failed), /did not seek/);
|
||||
} finally {
|
||||
mock.timers.reset();
|
||||
restore();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user