I have problem in my games, there is a freeze around every 15 seconds with absolutely no reason for it.
It completely ruins gameplay for some player with older computers.
I guess, it’s GC or something.
Here is the video of the problem: https://youtu.be/ajD9tyyfa40
You could try to profile it on chrome.
If it is the GC maybe you are creating objects every frame and piling up garbage too quickly?
If so, check the Lime’s ObjectPool class
If you compare both screenshots, the “Nodes” count is clearly a hint to the memory leak.
So it looks like something keeps creating nodes each frame, and they get garbage collected after some time ?
On a side note, I ran the Spector plugin to check the draw calls, and your main menu is clearly missing some clipping because you draw all menu items, even when they are outside of the screen ! Some logical clipping could make scrolling in this menu much smoother
Hey @ tour1st,
Thanks for optimizations tip, good idea, I will try it.
My thinking was that ~40 buttons whether with clipping or not should not make much difference.
Well, it seems to actually cost 2 draw calls per menu item : 1 for the image and 1 for the text below.
So rendering this menu takes at least 80 draw calls, which is already big for some old smartphones
Side note 2 : nothing seems to be batched, which makes performance even worse in-game because each card is drawn independentely. Using a texture atlas with all figures/numbers would help a lot in this case
Create a texture atlas of all the images you want to pack together (there are some tools around, but I can’t remember any of them…)
Load this big bitmap and createo a Tileset object with it
Then create a Tilemap object with this Tileset, with the dimensions of the game screen (for example)
Create one Tile object per image to display, and add it to the tilemap
Add the tilemap object to your stage (since it’s a display object) and voila ! All tiles attached to the tilemap will be rendered in the same draw call, so 1 tilemap = 1 draw call
I faced the same problem in my game. I can’t find what exactly causes this problem, but the frame rate has noticeably decreased and sometimes freezing, especially when using a bit of vector graphics. Had to return to 8.9.1 and all problems has gone. Not finding such problems on the forum, I decided that this applies only to my game (openfl shares context with away3d, etc.)
One thing we want to figure out is if OpenFL internally is allocating new objects repeatedly that must be garbage collected – I don’t know off-hand the easiest way to figure this out using HTML5 debugging tools but a reproduction case (especially a simple one) is a good place to start
After some tests, I think problem is with the TextField.
If I remove all the text from the game completely, there are no freezes.
Using filters (GlowFilter in my case) with text makes these Nodes drops on freeze, like in my first screenshot.
Without filter, there is no problem with Nodes, but JS Heap drops and still freeze: