A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
fix(render): release the atmosphere probe's WebGL context
Sameh Khamis20a03aad8789
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a74edbbae..dceec6a9c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,19 @@# Changelog+- Render on iPad and iPhone instead of stopping with "An error occurred while+ rendering." Cesium's per-vertex model atmosphere binds shader `out`+ parameters directly to varyings, which Apple's Metal/ANGLE backend cannot+ link, so the program failed and the render loop was torn down. The stage is+ now kept out of the pipeline on affected devices by clearing+ `scene.fog.renderable`, which leaves `fog.enabled` — and the fog density that+ drives 3D Tiles refinement — untouched. Detection is a WebGL2 link probe of+ the same pattern, so a future driver fix restores the effect with no code+ change, with iOS/iPadOS detection as a backstop. Sky atmosphere and the+ ground-atmosphere fragment path route through locals and are unaffected;+ affected devices lose distance fog on 3D tiles and on the globe basemaps.+ `src/app/atmosphereCompat.test.mjs` pins the probe, the platform matrix and+ the `renderable`-not-`enabled` choice (KnottyDyes, #705).+- Region scopes in voice analyst queries ("in the Gulf of Mexico", "overthe Alps") work again in the dev server: the bundled Natural Earth andneighborhood packs are fetched as JSON in the browser@@ -196,19 +210,6 @@ Analyst records for loaded satellites, datacenters and dams, with explicit boundretain geometry; incident-link checks abort on disable or selection change,and the row includes a containment legend.-- Render on iPad and iPhone instead of stopping with "An error occurred while- rendering." Cesium's per-vertex model atmosphere binds shader `out`- parameters directly to varyings, which Apple's Metal/ANGLE backend cannot- link, so the program failed and the render loop was torn down. The stage is- now kept out of the pipeline on affected devices by clearing- `scene.fog.renderable`, which leaves `fog.enabled` — and the fog density that- drives 3D Tiles refinement — untouched. Detection is a WebGL2 link probe of- the same pattern, so a future driver fix restores the effect with no code- change, with iOS/iPadOS detection as a backstop. Sky atmosphere and the- ground-atmosphere fragment path route through locals and are unaffected.- `src/app/atmosphereCompat.test.mjs` pins the probe, the platform matrix and- the `renderable`-not-`enabled` choice.-- Remove the spurious scrollbars that appeared on both panel stacks at narrowwidths (720px and below) as soon as a panel was expanded. The stacks scrollvertically there, and each panel's decorative glow, absolutely positioneddiff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.mdindex 92eccb9bd..348a25329 100644--- a/docs/CURRENT-STATE.md+++ b/docs/CURRENT-STATE.md@@ -701,7 +701,6 @@ snapshots, lifecycle actions and row descriptors. Remount and teardown removelisteners and row subscriptions; obsolete completions do not repaint old rows.The clear control presents busy state while its existing action owns the transaction.-## Model atmosphere on Apple MetalCesium's per-vertex model atmosphere is kept out of the pipeline on devices@@ -712,13 +711,15 @@ attaches that stage only when `fog.enabled && fog.renderable`, so the viewerclears `scene.fog.renderable` and leaves `fog.enabled` — and the fog densitythat drives 3D Tiles screen-space-error scaling — intact. Sky atmosphere and theground-atmosphere fragment path route through locals and are unaffected.+Affected devices lose distance fog on 3D tiles and on globe basemaps (Esri,+Bing, keyless), since the globe fog shader uses the same `renderable` flag.+The probe releases its throwaway WebGL2 context immediately.Detection is a WebGL2 link probe of the same out-parameter/varying pattern, so afuture driver fix restores the effect with no code change; iOS/iPadOS platformdetection is the backstop for when no probe context can be created. Appliedduring viewer construction, before any tile builds a draw command.-## Map Source control ownershipMap Source controls own chip listeners, source-state subscriptions and selectiondiff --git a/src/app/atmosphereCompat.js b/src/app/atmosphereCompat.jsindex 802f2b212..1bd23c8ea 100644--- a/src/app/atmosphereCompat.js+++ b/src/app/atmosphereCompat.js@@ -154,7 +154,19 @@ export function shouldDisableModelAtmosphere({} = {}) {const gl = createProbeContext();if (gl) {- if (probeOutParamVaryingLinkFailure(gl)) return true;+ let linkFails;+ try {+ linkFails = probeOutParamVaryingLinkFailure(gl);+ } finally {+ // Browsers cap live WebGL contexts (Safari especially); release the+ // throwaway probe context now rather than waiting for GC.+ try {+ gl.getExtension?.('WEBGL_lose_context')?.loseContext();+ } catch {+ // A context that cannot be released is left to GC.+ }+ }+ if (linkFails) return true;// Probe ran and the driver accepted the pattern. Apple mobile is still// quarantined: the probe program is far simpler than Cesium's, and a// false negative there costs the entire scene.diff --git a/src/app/atmosphereCompat.test.mjs b/src/app/atmosphereCompat.test.mjsindex 7f601512b..f1c1d43bf 100644--- a/src/app/atmosphereCompat.test.mjs+++ b/src/app/atmosphereCompat.test.mjs@@ -207,3 +207,15 @@ test('tolerates a scene with no fog object', () => {assert.equal(applyModelAtmosphereWorkaround({}, {}), false);assert.equal(applyModelAtmosphereWorkaround(null, {}), false);});++test('releases the throwaway probe context after probing', () => {+ let lost = 0;+ const gl = fakeGl({ linkOk: true });+ gl.getExtension = (name) =>+ name === 'WEBGL_lose_context' ? { loseContext: () => (lost += 1) } : null;+ shouldDisableModelAtmosphere({+ navigatorLike: LINUX_DESKTOP,+ createProbeContext: () => gl,+ });+ assert.equal(lost, 1, 'probe context must not linger until GC');+});