-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use "WEBGL_lose_context" to destroy WebGL context in Map#remove #2656
Comments
Backstory - I did some work on this back in #2019 (click through and see the "outdated diffs" for more info). We are kind of at the mercy of the garbage collector to clean up unused webgl contexts, and that doesn't always happen immediately. |
@bhousel Do you know of anything we can do in GL JS to ameliorate the situation? If not, should we close this ticket as "not actionable"? |
There are delete calls we could make for the underlying resources, and that potentially-sketchy SO answer also claims that resizing the canvas to 1x1 will reduce the amount of memory it consumes until it's GC'ed... shots in the dark but worth a shot |
hmm, just realized there is a WebGL extension to intentionally drop the context - that might help? |
There is a related thread happening now on the webgl developers list, for anyone looking for tips on how to free up webgl contexts: https://www.khronos.org/webgl/public-mailing-list/archives/1611/msg00013.php |
For anyone who comes across this... I use a work-around to show and hide the map canvas rather than redraw the map each time and that fixed my WebGL context issues. Not perfect but acceptable in my use case. |
Can you please share your workaround. |
@adoming3 can you please share your workaround? |
mapbox-gl-js version: 0.19.0
Chrome 50
Steps to Trigger Behavior
.remove()
the mapExpected Behavior
No warnings or errors should occur.
Actual Behavior
After a certain number of iterations (about 10 for me) there is a warning in the console
Too many active WebGL contexts. Oldest context will be lost
. This error indicates that the GL context is not being cleaned up when the map is removed.The text was updated successfully, but these errors were encountered: