Skip to content
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

Closed
scothis opened this issue Jun 2, 2016 · 8 comments · Fixed by #2950
Closed

Use "WEBGL_lose_context" to destroy WebGL context in Map#remove #2656

scothis opened this issue Jun 2, 2016 · 8 comments · Fixed by #2950

Comments

@scothis
Copy link
Contributor

scothis commented Jun 2, 2016

mapbox-gl-js version: 0.19.0

Chrome 50

Steps to Trigger Behavior

  1. create a map
  2. .remove() the map
  3. repeat

Expected 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.

@bhousel
Copy link
Contributor

bhousel commented Jun 2, 2016

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.

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 9, 2016

@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"?

@tmcw
Copy link
Contributor

tmcw commented Jun 9, 2016

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

@bhousel
Copy link
Contributor

bhousel commented Jun 10, 2016

hmm, just realized there is a WebGL extension to intentionally drop the context - that might help?

@lucaswoj lucaswoj changed the title Leaking WebGL contexts Use "WEBGL_lose_context" to destroy WebGL context in Map#remove Jul 29, 2016
lucaswoj pushed a commit that referenced this issue Aug 5, 2016
lucaswoj pushed a commit that referenced this issue Aug 8, 2016
* Make benchmark runner able to run multiple benchmarks

fixes #2405
fixes #2656
fixes #2800

* Update benchmark readme

* Switch from "reactify" (deprecated) to "babelify"

* Support running a single benchmark
@bhousel
Copy link
Contributor

bhousel commented Nov 8, 2016

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

@adoming3
Copy link

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.

@meenu1
Copy link

meenu1 commented Mar 14, 2018

Can you please share your workaround.

@kamillejohnson
Copy link

@adoming3 can you please share your workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants