pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.33k stars 177 forks source link

Possible memory leak when unmounting #320

Closed Specy closed 2 years ago

Specy commented 2 years ago

Description

I made a memory profile for the first time today and think that i have a memory leak in my app (somewhere, i have no idea how to find it), i've looked through the code and i dont think i can find anything which might cause it. One thing which i did notice tho was that whenever i change page (so in theory unmounting the parent that holds the Stage) and then go back to it (4/5 times), i get: WARNING: Too many active WebGL contexts. Oldest context will be lost.. Do i have to do something to specify that the old context should be disposed or i'm rendering in a wrong way? If i remove the component that has the canvas (ComposerCanvas.js) from the page, the leak seems to almost disappear

My code: here (i'm aware that it's not the prettiest code out there but i had to do many things im not proud of for the sake of performance)

App that is having problems: here

Additional info

inlet commented 2 years ago

Duplicate #313

Basically it means that mounting a <Stage> component it creates a PIXI.Application which instantiates a WebGL context. This is related to PIXI itself and it is harmless.

In this (react-pixi) lib we destroy the application on unmount, however PIXI caches the webgl context ids in memory causing the warning to be thrown at the console. I've made several tests and I cannot see any memory leaks relating to this.

I'm pretty sure it's something else that might causes performance issues.

Closing this issue, please let me know if you think we should reopen it. Thanks!