iOS kills the web workers while the page is backgrounded and the map can never load tiles again
maplibre-gl-js version: 6.9.0
browser: iOS Safari and iOS WebView. Simulatable in any browser.
Steps to Trigger Behavior
- Open a vector or GeoJSON map in iOS Safari.
- Leave the page in the background long enough for iOS to reclaim memory (typically 5-30 minutes under some memory pressure).
- Return to the page and pan to unloaded areas.
Link to Demonstration
There's no way to trigger the termination on demand from page JavaScript, so a jsbin can't show the iOS path directly. You can reproduce the identical broken state in any browser with this CodePen by clicking a button that calls terminate() on the workers, then panning.
Expected Behavior
New tiles load. The map continues to function as normal. (Or, at a bare minimum, can be recreated.)
Actual Behavior
Blank areas forever, with nothing in the console. iOS terminates the workers without firing any event (see WebKit 211018, Apple forums 758346), and the library can't recover. WorkerPool caches its workers in one promise, and the RTL plugin singleton keeps the pool's active count above zero, so even map.remove() plus a new Map reuses the dead workers.
Prior Art
https://github.com/maplibre/maplibre-gl-js/issues/8192 added a public API to check if the workers had been terminated. I'd like to work a way to automatically recover from it, as @HarelM requested.
cc @ingalls
Source: maplibre/maplibre-gl-js