nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
667 stars 170 forks source link

Proper way to remove stage? #532

Closed ehb54 closed 6 years ago

ehb54 commented 6 years ago

I'm using stage to create viewers dynamically, but eventually I get a console error (just testing in Firefox for now). Error: WebGL warning: Exceeded 16 live WebGL contexts for this principal, losing the least recently used one. I believe I am .dispose()'ing the stage each time and deleting all references to it... Reusing a pool of fixed stage is not really a trivial option in this case, since multiple "modules" can each have an arbitrary number of distinct viewers. Is there any guidance for properly removing a stage?

Thanks, Emre

1auralynn commented 6 years ago

I had the same issue and I resolved it by calling stage.removeAllComponents() and then stage.dispose()...

arose commented 6 years ago

Using stage.dispose() should be sufficient, can you make sure it is called?

ehb54 commented 6 years ago

Yes, stage.dispose() was called. console.log()'d it, but I'll verify again and report back.

cjeong73 commented 6 years ago

I checked stage.dispose() was apparently called. Then, I tried to call stage.removeAllComponents() before stage.dispose() as 1auralynn suggested, but it is not sure "what components" should be removed because removeAllComponents() requires a string, probably a collection of components of Stage. I am new to NGL, could 1auralynn help me to properly define a component list?

1auralynn commented 6 years ago

Hmm strange, I was able to call stage.removeAllComponents without a string variable...

Laura Lynn Gonzalez Owner, Dynamoid http://dynamoid.com Oakland, CA

On Fri, Nov 2, 2018 at 1:47 PM, cjeong73 notifications@github.com wrote:

I checked stage.dispose() was apparently called. Then, I tried to call stage.removeAllComponents() before stage.dispose() as 1auralynn suggested, but it is not sure "what components" should be removed because removeAllComponents() requires a string, probably a collection of components of Stage. I am new to NGL, could 1auralynn help me to properly define a component list?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arose/ngl/issues/532#issuecomment-435497694, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfolwmeZCPYqwpw0pkmuxxwOo1oDwcNks5urK9YgaJpZM4T2jXj .

ehb54 commented 6 years ago

After some digging, and testing with chromium-browser --js-flags='--expose_gc' to expose the window.gc() command to force garbage collection, our conclusion (cjeong73 & myself) is that this is not an NGL issue but a javascript garbage collection issue. Once garbage collection is forced, the error goes away. Unfortunately, there seems no way to force javascript garbage collection. So I push this issue to the browsers and their javascript engines. Note: we did not have to call .removeAllComponents(), just simply .dispose().