Jump to content

WebGL lost context issue


Stan
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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 by Stan
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...