Mobile browsers crash after loading/unloading a few maps
v0.24.0:
Steps to Trigger Behavior
- Load a map in a page container div
- Remove the container from the DOM (as in a React page transition)
- Repeat 3-6 times
Expected Behavior
No crash
Actual Behavior
The tab will crash on mobile Safari and Chrome on Android. Is it required that we call map.remove() or is that done automatically?
These crashes are likely due to allocating too many WebGL contexts on a page. Calling Map#remove will release the WebGL context and allow you to delete / create maps indefinitely.
Please re-open with a demo if Map#remove doesn't solve your problem.
@lucaswoj map.remove() on componentWillUnmount() did not solve the issue for me.
In this fiddle, reloading 9 times causes a crash in iOS: https://jsfiddle.net/jnorris441/24rgc7L4/1/
I'm not seeing a crash, since I'm not on a mobile device, I guess. But what I'm seeing is increased memory usage after each reload. It seems that there are several severe memory leaks. After reloading five times the JS heap grew from 52MB to 78MB.
Could it be that the mobile device is just running out of RAM for the browser?
@philpl That sounds likely
@philpl @jnorris441 did you guys ever identified the cause / fix for this leak? we're running into a similar issue here https://github.com/uber/react-map-gl/issues/167
@abmai I don't have any insights on hand. This could be a memory leak in GL JS, WebGL, or Chrome. Have you run the Chrome memory profiler on your use case?
@lucaswoj - I only quickly used the timeline to ascertain of a leak. will do some deeper digging and send updates in the react-map-gl issue I linked
Thanks @abmai. I'll follow the linked issue.