Check a parked renderer's real WebGL context before reuse and rebuild it when the context is lost

This commit is contained in:
German Khokhlov committed 2026-11-03 22:56:24 +04:00
1 parent 01ae045346
commit 9f8381ff71
2 files changed
+15 -3

No files matched your search

+6 -1
View File
@@ -8,7 +8,12 @@ export function createRendererCache() {
const host = document.getElementById('cesiumContainer');
let entry = idle.get(kind);
idle.delete(kind);
if (entry?.lost) {
// loseContext() takes effect before its queued DOM event is delivered.
// Check the existing context too, before resuming a parked render loop.
const canvas = entry?.scene.engine.host.canvas;
const context =
canvas?.getContext?.('webgl2') ?? canvas?.getContext?.('webgl');
if (entry && (entry.lost || context?.isContextLost())) {
entry.dispose();
entry = null;
}