Mapbox GL JS v3.3: Uncertain WebGL Context Eviction When Exceeding Browser Limits
0 reputation · 30 Apr 2023, 20:08 UTC
Uncertain WebGL Context Eviction in Mapbox GL JS v3.3
In single‑page applications that instantiate a new Mapbox map on each route change, the map.remove() call is required to release the underlying WebGL context and worker threads. The browser enforces a hard cap on active WebGL contexts (≈8–16 depending on engine), and once the limit is hit the WebGL spec allows the user agent to lose any context, typically the most recently created one. Mapbox GL JS does not expose which map instance will be evicted, so developers cannot predict which map will stop rendering after the cap is exceeded.
Key uncertainties remain:
- Which WebGL context does a browser lose when the limit is reached in the context of Mapbox GL JS v3.3?
- Is there a way for Mapbox GL JS to provide a deterministic eviction policy or a callback before loss?
- Can applications detect the impending loss early enough to remove or recreate maps proactively?