fix(web): add shared DemSource singleton, add ErrorBoundary, and conditional view rendering to prevent WebGL crash

This commit is contained in:
Hamza-Ayed
2026-08-18 12:35:17 +03:00
parent ba4ae15eab
commit c9b3249aa5
5 changed files with 119 additions and 70 deletions
+2 -10
View File
@@ -1,16 +1,7 @@
import React, { useState, useEffect, useRef } from 'react';
import maplibregl from 'maplibre-gl';
import mlcontour from 'maplibre-contour';
const demSource = new mlcontour.DemSource({
url: 'https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png',
encoding: 'terrarium',
maxzoom: 15,
worker: true,
cacheSize: 100,
});
demSource.setupMaplibre(maplibregl);
import 'maplibre-gl/dist/maplibre-gl.css';
import { getSharedDemSource } from '../utils/demSource';
import {
Shield,
Crosshair,
@@ -456,6 +447,7 @@ export const TacticalDefenseView: React.FC = () => {
});
// Dynamic On-the-Fly Contours from Elevation DEM
const demSource = getSharedDemSource();
const contourUrl = demSource.contourProtocolUrl({
thresholds: {
10: [100, 500],