mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Check a parked renderer's real WebGL context before reuse and rebuild it when the context is lost
This commit is contained in:
1 parent
01ae045346
commit
9f8381ff71
2 files changed
+15
-3
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user