mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Report a panel's render errors in full and restart drawing
Cesium stops drawing after a render error and prints worker failures as [object Object]. An inline panel now logs the error's details and starts drawing again, up to three times.
This commit is contained in:
1 parent
47742f335d
commit
5ad0dd0004
2 files changed
+82
-1
No files matched your search
@@ -246,3 +246,44 @@ test('a panel keeps drawing from a timer while animation frames stop', () => {
|
||||
assert.equal(tick, null);
|
||||
assert.equal(frame, null);
|
||||
});
|
||||
|
||||
test('a panel reports a render error in full and starts drawing again', () => {
|
||||
let listener = null;
|
||||
const timeouts = [];
|
||||
const windowRef = {
|
||||
requestAnimationFrame: () => 1,
|
||||
cancelAnimationFrame() {},
|
||||
setInterval: () => 1,
|
||||
clearInterval() {},
|
||||
setTimeout: (fn) => (timeouts.push(fn), timeouts.length),
|
||||
clearTimeout() {},
|
||||
};
|
||||
const viewer = {
|
||||
useDefaultRenderLoop: false,
|
||||
scene: {
|
||||
renderError: {
|
||||
addEventListener: (fn) => ((listener = fn), () => (listener = null)),
|
||||
},
|
||||
},
|
||||
};
|
||||
const logged = [];
|
||||
const original = console.error;
|
||||
console.error = (...args) => logged.push(args.join(' '));
|
||||
try {
|
||||
const stop = keepPanelRendering(viewer, { windowRef, now: () => 0 });
|
||||
for (let attempt = 0; attempt < 5; attempt++)
|
||||
listener(viewer.scene, {
|
||||
name: 'RuntimeError',
|
||||
message: 'worker failed',
|
||||
});
|
||||
assert.match(logged[0], /render error: .*"message":"worker failed"/);
|
||||
// Only a few restarts, so an error that repeats does not spin.
|
||||
assert.equal(timeouts.length, 3);
|
||||
timeouts[0]();
|
||||
assert.equal(viewer.useDefaultRenderLoop, true);
|
||||
stop();
|
||||
assert.equal(listener, null);
|
||||
} finally {
|
||||
console.error = original;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user