Stan Posted January 15, 2021 Share Posted January 15, 2021 Hello guys, I have a bug that has been bothering me for a week. On ios14+, WebGL is totally crashing and losing context. There is a runtime error WEBGL_context_lost or something, but only after I refresh the safari browser. Even browser refresh doesn't fix the context immediately. I have implemented a swipe functionality with pixi v4.8.8 and the bug occurs when I start swiping rapidly between pages for a minute or two. After a while the game just freezes. The way I implemented the logic is on every swipe I do removeChild then addChild to 10-12 DisplayObjects. Basically I remove old Sprites and then create new ones on every swipe. There is no Heap memory leak. The only thing I can think of is if there is a GPU memory leak somehow, but I think PIXI should be able to handle simple adding and removing sprites. Any ideas what causes that issue? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 15, 2021 Share Posted January 15, 2021 v5 can recover from lost context , but i dont remember how exactly. For v4 we cant guarantee that at all. At why does it happen after refresh - honestly, its Safari. Anything can happen. addChild-removeChild cannot affect it, what actually affects it is texture upload which happens every time texImage2D is called, usually when texture is rendered on screen for the first time. Whats the total size of all your textures (not gzipped, not png-ed, just total size in pixels)? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 15, 2021 Share Posted January 15, 2021 Btw, pixi does not have any memory-related analytics. You have to install spectorJS extension to count your memory, or maybe include "spector.js" in your project when its in debug mode Quote Link to comment Share on other sites More sharing options...
Stan Posted January 18, 2021 Author Share Posted January 18, 2021 (edited) Hi, Ivan. Thank you for replying. I have literally tried everything I could think of and I'm out of ideas. As for your comments: I cannot migrate to v5, I'm stuck with v4. I didn't explain it well enough. It happens only on apple devices with version 14.x. Safari and Chrome. I read some threads online about that problem. Apparently there is a bug with ios and ipados v14 and this context losing issue. I'm using an atlas sprite for images generated from TexturePacker. I load the atlas once, then I used these textures to create a sprite. I will check it out for sure. I can manage and monitor CPU memory management, but I don't think I can do the same with GPU's. And may be the problem lies there. It is really weird. The bug only happens after a huge amount of swipes back and forth, but still is a big issue and should not happen. There is only one thing left for me to do, refactor the whole thing by creating the object when the constructor is called, make them visible false, and only populate the data on swipe and make then visible true, instead of every time adding and removing, but this is will be a huge refactoring, and I'm not even sure that will work. Really need ideas what could fix that problem. Edited January 18, 2021 by Stan Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 18, 2021 Share Posted January 18, 2021 Pools and pre-populating should be used only if you are sure it'll work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.