Sign in to follow this  
Arcs

PIXI onunload or onbeforeunload to free up all elements

Recommended Posts

I'm not sure this is needed, but it seems it would be since if I refresh the game I'm working on enough I eventually get this in firefox:

 WebGL warning: <SetDimensions>: Exceeded 16 live WebGL contexts for this principal, losing the least recently used one.

So I was wondering if when you refresh a browser window if canvas and other stuff stays in memory or the gpu since it only happens if I hit f5 enough times while checking changes to the game.  Was wondering if this too could explain some slow downs I see sometimes.

So is there any way to just have pixi totally unload/destroy all objects on an unload event or is this going to be done automatically anyway when you reload a window?

Share this post


Link to post
Share on other sites

Yea I did get it with ctrl + f5 also with dev tools open and disable caching selected.  ctrl + shift + f5 doesn't seem to do anything in FF tho I tried it too.

One thing I noticed though is it seems to reset it if I close the tab and open a new one, still makes me wonder if it's leaving stuff live somewhere though even after unload/close and it's just not attached to the current tab so it doesn't show the warning.

Share this post


Link to post
Share on other sites

It should be dead. I think the problem is actually that your App initialization depends on browser cache and something goes wrong with events, and your app initializes 14 times. Another possibility is that I really dont know modern UI frameworks and instead of full refresh browser just hits the anchor of your page and forces re-load of app router. Which UI framework do you use?

Share this post


Link to post
Share on other sites
PIXI.Loader.shared.add(visualassets).add(state.sound_preload).on('progress',loadingbar).load(prerungame);
function loadingbar(var1){
	$("#loading .bar").css('width',var1.progress+'%');
}

That's our initialization.  The warning only happens if I f5 in the same tab like 15 times.

We don't use any UI framework unless you want t include jquery or something, only characters, backgrounds and spine files are rendered in PIXI the rest is outside the canvas such as text or even hp bars.  prerungame will in order load objects from the game and create the necessary things in canvas with pixi, when that is done the loading screen is hidden and the animate loop can start.  I usually have the developer tools open in firefox with caching disabled so I don't have to worry about getting a fresh copy on page refresh.  I work locally so downloading stuff each time is no problem.  In prerungame our canvas gets drawn with PIXI per settings parsed from text.

Share this post


Link to post
Share on other sites

I create the stage and the renderer as part of the loading of the game, after the PIXI loader loads all assets.  This can only ever be called once since it is only ever called from prerungame which is only called from PIXI loader finishing.

Share this post


Link to post
Share on other sites

Both are growing :( browser mem was 18.9 then on up to 29 after enough reloads, and my gpu mem started at like 1.3 gigs used and is now at 1.7 (note I went off total gpu memory not just the browser).  They both clear out, though not right away, after closing the tab.

 

Edit: Tried the same test on chrome, no growth :(  So that means it's a firefox select issue then?

Share this post


Link to post
Share on other sites

https://bugzilla.mozilla.org/show_bug.cgi?id=1501142

Well it's nice to know it's not my game.  I almost wonder if it was a design choice by someone for a reason since they capped it purposefully at 16, maybe to prevent some forms of memory being called for that was cleared up for some reason idk, keeping 16 refreshes in memory isn't the most common choice here tho.

Thanks for the help!  Learned something and got relief it wasn't my game causing it.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.