Jump to content

Chrome freezing


stealman
 Share

Recommended Posts

Hello I have pretty well working MMO that runs greatly even on my Galaxy S3 but there is a problem ..

When playing on Android devices and Chrome, after about 20 - 30 minutes of playing FPS starts to drop until whole Chrome freeze completely. Must be killed and run again.

It always take long time to reproduce and it is frustrating as I have absolutely no clue whats the cause .. what I know

1 - No memory leaks possible as I have debugged via Chrome Developer Tools (USB cable connected phone to my PC) and memory oscilates between 10 - 20MB from

start to the end ..actually nothing that Chrome CPU log can trace was increasing in number really nothing. If you have looked on that CPU log you would say that "no problem occured" but game still freeze .. it is like 20 minut absolutely ok .. then laggs starts gets worse until totally freeze.

2 - I was trying to run android native CPU monitor overlay to see what happens in real time and here is the thing

Android show green bar as user process CPU time and red bar as Kernel process CPU time - when everything is going well only green bar is visible (red is around 10%) ..but after it goes to mess up .. then red bar is raising until it is 95% red Kernel bar and almost nothing is green user process bar.

 

Well I dont suppose that you could help me directly .. I would rather now whether someone else has simmilar experience as I dont know where to start troubleshoot .. I have tried everything. On desktop PC problem never occurs. Offcourse no javascript errors on console.

 

Thanx in advance for your experiences.

 

 

 

Link to comment
Share on other sites

14 minutes ago, ivan.popelyshev said:

Something leaks videomemory. Do you have textures that you create dynamically from canvas? Text objects, or Meshes that you forgot to destroy()  after use?

FYI there is no dedicated video memory on such devices, textures are stored in the same RAM as used for everything else.

How are you playing audio, there has been talk of issues with Chrome leaking memory with playing audio...

Link to comment
Share on other sites

Thanx guys I really appreciate your help and I know it is difficult to remote troublehsoot. I have maybe also some useful info for you as I have observed memory leaks.

1. Memory leaking WAS problem .. I am facing this freeze issue for several months and I HAD memory leaks of two types

 - textures for generated animations (they stacked up really quickly and WERE accounted by chrome as memory usage) forgot to destroy them - SOLVED

- PIXI.Text objects was second problem (more difficulty to find) as I didnt call destroy on them .. it took more time but Text objects as well DID cause memory leak - SOLVED

but again it WAS counted as memory usage by chrome.

 

So you are right about memory leaks I had them but I dont have them anymore. Memory usage on android itself is stable, as well as in Chrome developer "Timeline" analyzer.

What is in my opinion theoretically possible is fact, that some "data" might be stored in "GPU memory .. if my Galaxy has something like this" and it is not "visible" as used memory by Chrome itself. It is perfectly possible BUT as Chrome detected both my previous memory leaks .. I kinda doubt that. I dont know how WebGL works internally :(

 

But mister CHG .. your question about audio might be relevant because I have some simple wav sounds and there is another weird behavior. They wokrs ok for several minutes AND then they suddenly stop to play at all (again no error visible) and this problem is only on Android Chrome .. IPAD or PC is ok. So sounds theoretically might cause some problem (untrackable sadly). But again . nothing seems to consume memory .. it is more like something consume CPU.

 

I was also monitoring garbage collection rate in Chrome and it remains constant for all the time. 

 

2. What I have pointed out before is what scares me most .. native android CPU activity monitor shows increasing consumption of KERNEL processes and decreasing time to count "user process" .. From Android own point of view is whole "Chrome Application" probably "user process". It looks like that not only javascript is overwhelmed but system itselfs is overwhelmed by kernel processes and dont have spare time for application processes.

 

3. I had also one CPU leak - DOM element were cleared by .innerHTML = '' and that leads to forgotten event lisneters and consumed lot of CPU time. When I have found that I was really happy :-D But sadly .. it didint solve THIS problem either :( For those of you who might not know this .. jquery .empty()  function resolved it. (Tested and proven many times)

 

4. I am on PIXI 2 ... I have tried to migrate to PIXI 3 but problem was reproduced exactly the same way. Actually after migration to V3 I had problem on IPAD as I have tilebased background - there were SOMETIMES thin black space between tiles (with thin I mean 1 IPAD native pixel .. even less than 1 "my html pixel" ) no problem on PIXI v2 thats why I still have v2 running.

 

Finally to me it seems that every "my fault" that I have discovered already was easily found through Chrome developer tools but not this one and it is really scary that it alsways happens and always after 20 - 30 minutes of absolutely perfect performance. No memory "ups and down" .. nothing actually indicate problem until it is too late .. it is like cancer.

And once more I am really thankful for your help and I hope that my observations might help to someone else as well. I will download some better android memory analysis application to try to find "hidden memory leak"

EDIT: This problem was reproduced on several Chrome devices .. actually on all of them it just took different amount of time so it is not problem of one specific device.

 

 

Link to comment
Share on other sites

Quote

Well you can test if the problem stays with CanvasRenderer. If its gone, then its WebGL memory leak.

This is good idea !! I will definitely try it at sunday it should not be problem and it might tell me something more. 

In scenario where CnavasRenderer will be fine .. is here something more I can do ? I mean to troubleshoot where the problem is ... I have tried lot of monitoring and nothing indicate to memory leak. But I am also suspicious to WebGL maybe I am doing something wrong with PIXI.

For example - I dont use sprite.destroy()  .. I am just removing these sprites from Stage object and from whatever object that referencing it, but I  think that it would cause visible memory leak and not this "undetectable" one and my memory is really fine according to Chrome developer tools. :)   

Biggest problem is that it is difficult to reproduce .. each testing attempt needs 30 minutes of playing to see results :)

One of my observations is .. but probably only subjective .. I feel that time needed to reproduce problem does not depend too much on what I am actually doing in that game.

But thanx, that renderer idea is really useful, I will definitely try it ASAP.

I will let you know then. Thanx to all of you.

Link to comment
Share on other sites

Hello again I have some new clues !! I have switched to CanvasRenderer and something changed. The problem itself didnt disappear but now I can see memory consumption raise incrementaly.

I have done some research and I have found one problem that I was sure I am doing right accoridng to PIXI documentation but probably not. It is pretty simple what causes memory leak.

I have one sprite with character image and that character can speak. Whenever character speaks I create new PIXI Text object.

This text object is then ADDED as a child to that character sprite (to follow character as he is moving) also TIMER is triggered.

After that timer is over, I remove that TEXT object from Character sprite var removed = speaker.removeChild(txtObject);

This removed object is that PIXI Text object added before.

Then on next line I call removed.destroy(true); to remove texture from memory.

I really dont know what am I doing wrong .. this text object does not have any other reference anywhere it is only attached to Character sprite and then removed and destroyed.

 

Dont you have some clue what am I doing wrong ? Character sprite itself remain untouched during the process.

 

EDIT: I am using PIXI Text in more occasions and it looks like they consume lot of memory in other use cases as well, thers must be something that I miss. Maybe I shall have some "Pool of Text objects and reuse them .." but that would be really annoying.

 

 

Link to comment
Share on other sites

3 hours ago, stealman said:

EDIT: I am using PIXI Text in more occasions and it looks like they consume lot of memory in other use cases as well, thers must be something that I miss. Maybe I shall have some "Pool of Text objects and reuse them .." but that would be really annoying.

If you are creating and destroying any kind of object with relitive frequency, then you should absolutely be pooling them. Creation/Destruction is really expensive, especially with Text objects.

Link to comment
Share on other sites

Helo as I was trying that CanvasRendered .. I was able to find more memory leaks (I didnt see them before in WebGL mode). The problem was in my another "composed" object.

I had Sprite with another Sprite as its child and while removing first sprite from stage I didnt destroy texture of that child sprite (didnt know that I have to sorry).

This Object.keys(PIXI.BaseTextureCache).length;  saved me .. I couldnt find that mistake without this, you helped me a lot. I will monitor this variable whenever some problem appear. I am not sure yet whether removal of these memory leaks will help but I suppose it will.

 

3 hours ago, xerver said:

If you are creating and destroying any kind of object with relitive frequency, then you should absolutely be pooling them. Creation/Destruction is really expensive, especially with Text objects.

I am thinking about it .. but if I will use textObj.setText instead of creating new ones .. wouldnt it result in original texture being stored forever as I will set new text content ?

Or is there some other way how to "recycle" text objects without leaving "deprecated" textures laying on cache forever ?

Something like

textObj.texture.destroy(true);

textObj.setText("Some new text")

I am creating and destroying text objects quite often, so it could improve performance little bit if it is valid approach.

Thank you very much for all that help .. especially Object.keys(PIXI.BaseTextureCache).length; this is useful for troubleshooting .. I would never find these leaks without it.

Link to comment
Share on other sites

Is Memory increased continuously if PIXI.Text are created real time like chat system..?

My game has chat system and if users write text added on chatting window

 

how about using pixi-cocoontext instead of  pixi.text?

 

thx..

 

 

 

 

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...