Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

Keep the panel's 2D canvases in memory

Sameh Khamisd0da4b072217
diff --git a/src/app/globePanelRuntime.js b/src/app/globePanelRuntime.js
index 879630c19..2e38d63dd 100644
--- a/src/app/globePanelRuntime.js
+++ b/src/app/globePanelRuntime.js
@@ -341,6 +341,16 @@ export function panelRuntime(config) {
};
window.Worker.prototype = NativeWorker.prototype;
+ // Some hosts drop the GPU contents of a panel's 2D canvases while they
+ // consider the panel off screen, and the overlays then cover the globe
+ // in black. Keep 2D canvases in memory instead, which hosts do not drop.
+ const getContext = HTMLCanvasElement.prototype.getContext;
+ HTMLCanvasElement.prototype.getContext = function (type, options) {
+ return type === '2d'
+ ? getContext.call(this, type, { ...options, willReadFrequently: true })
+ : getContext.call(this, type, options);
+ };
+
// Markup the app adds as HTML text would request its images from this
// page's site at once; hold their addresses until the files are here.
const htmlWithHeldImages = (html) =>