Performance Issue in 1.7



I sense there is some issue on the web-mobile on the 1.7.

It seems that the first time anything happens, its very slow, but then the next time performance is increased to normal.

Example, Breaking Gashapon:

(This is a running normal example)

This spawns some bodies and also plays some animations.

On Desktop it goes well since the first run.

Because on mobile on the second time and beyond it runs fine, I think its not a problem with the action itself (like spawning too many bodies).

Is there any tricks to prevent this?

ps. Using the chrome debug tools, I found out that the disk is not being acessed (everything seems loaded properly, even prefab stuff, on the loading screen). So I don’t know what is being loaded.


You might try instantiating a pool of objects before the first action is taken?


Well, that may solve the issue.

I can also always run all the objects for given scene before the game starts and call it part of the ‘loading’ phase.

But since it just happens on the very first time I wonder if there’s something I’m missing or a better way to solve the problem.

But its not somethign specific, its also shader application and really any other stuff, although all the stuff seems already loaded in memory. (I mean, all cocos2d.js min, all project.js, and all sprites).

I wonder why would I need to ‘wake’ some stuff, if maybe parts of the code are not loaded for some reason and theres a way of globally loading them more easily.




pool of objects didnt help.

only instantiating a few bodies randomly berore the game start seem to solve the issue.

its probably something within box2d js that gets reallocated/ initialized.


After taking a deep look at the profiler, i realized that in general, everything is optmized over time.

The more times you execute things, it seems that the cocos2d library creates compiled functions or shorcuts. And its not just the JIT, but a whole bunch of stuff.Actions, sequences, loads, instantiations…

I guess thats really sad for me, I wanted to make a cordova based web game but it seems too unreliable performance-wise :[

Oh well, back to the lab again.


here’s an example of a cc.RunAction sequence that is executed on the onLoad of the candy of the gashapon,

The first time it takes a LOT fo time, the second time less time, and then its like instantaneous.

And this happens on web too. Its just that it jumps from 60 fps to 47 fps, the frame step jumps from 2 to 5 ms, but thats barely noticeable.


I wonder if there’s a way to play the game and then save a cached file that can be loaded upon playing the game?

@phero_constructs do you know anything about it?


I’m not really sure. Can you record a video from the device so we can see exactly what is happening?


Its ok, Its impossible to save the inline caches optmizations :frowning:

This only makes sense because I’m using web-mobile (javascript stuff).

I’ll have to build natively… compiled code will execute better and object pooling will increase performance consistently.


Just a thought, could you fire off the first action during a loading screen?


Yes, and that totally worked.

I have a script to execute stuff on a ‘loading’ scree now, on mobile.

I build a cc.Sequence and execute a lot of things a lot of times, the framerate drops to 1, but then its very fast!

Its a shame cocos creator doesnt export directly to cordova, they are missing a big potential of their engine.

(I gave up using native because the result is way too different and too troublesome to debug, you cant just type stuff in the console like web).