0 Favourites

Mobile / cocoonjs optimisation tricks ?

  • Hi everyone, I spent my last days trying to optimize my game for mobile (already read all performances tips). The game is a simple horizontal runner game, with one long layout (500*100,000 pixels). I use cocoonjs 1.3 to export it on mobile.

    What is strange is that i achieve a 60-62 fps on my Galaxy Note 2, about the same rate on my desktop PC, but the sprites and background on mobile are not scrolling smoothly like on my desktop.

    It's like every second there is a micro-freeze or lag of the sprites or tiles elements. The FPS is not really dropping when it occurs, it stays at 58-62. The feel is better on Iphone 5 though, but on android even with high FPS the scroll is not smooth.

    Is the issue on CocoonJS wrapper? Somebody else experience such thing ?

    I don't use any effect, I tried to disable some behaviours, use tiny sprites, I haven't found the cause.

    For scrolling I use :

    * EveryTick > System : set scroll X to player.X + 150

    * player have a bullet behaviour with a speed of 300.

  • Your playfield area its too huge.

    In our game, Sigurd's Havoc, we used a static playfield with moving background, giving the impression of falling in a "infinite" level. All enemies and game elements are created dynamically. These elements are also destroyed after leaving the game screen, reducing the number of objects.

    Maybe this can help you to reduce these micro-freezes.

  • Keyo

    is it possible that you upload a sample capx.? I'm very interrested in your technique since i was trying to do this too but never achieved a good looking result.

  • The layout size should not affect anything, since it's basically only used to limit scrolling.

    The micro-pauses are probably garbage collection. There isn't much you can do about it, since Javascript is a garbage collected language. The latest build (r123) has some small improvements which might help, and often it clears up after 20-30 sec (once it's got the main garbage out the way).

  • Ok Ashley, Ludei told me the same thing, that "it's probably garbage collecting, on js or java side".

    I will try the last build with the hot fix tomorrow.

    However, I wonder if I decrease the game screen resolution (window size) of the game exported to cocoonjs, could it boost the performance or memory used ? Or is it unrelated ?

  • The layout size should not affect anything, since it's basically only used to limit scrolling.

    The micro-pauses are probably garbage collection. There isn't much you can do about it, since Javascript is a garbage collected language. The latest build (r123) has some small improvements which might help, and often it clears up after 20-30 sec (once it's got the main garbage out the way).

    So, Scirra don't can solve this micro-pauses question? I playing many mobily games that are made with C2. E.g. Hungry Hal. And much more. All have the micro-pauses. This doesn't inspire me to buy the C2 personal or business license...

  • Alatok

    Yes, you can make great game with Construct 2 but you have 0% guarantee that it will work well on any platform Anyway I disagree with you - Hungry Hal by ArcadEd works quite well, thanks to ludei. From the other hand jittering is very visible on Star Nomad by Silverforce, thanks to Crosswalk and bad Chromium.

  • szymek Star Nomad on iOS is damn smooth. Thanks to WKWebView. Minor bugs aside, its perfect in terms of performance.

    I have had zero user complaint on Android regarding stutter, only a bunch of "app crash, 1 star" from users with ancient devices that don't even meet my minimum specs. On my own devices, it stutters for the first 20-30 seconds (which is fine for some games) but after that it smooths out. It behaves differently than Chrome 38+ where the random stutter is just there all the time.

    I did have random stutter on CJS Android with Canvas+, for both Star Nomad & Ninja Girl, but I'm happier with Crosswalk for them both now.

    Android:

    iOS:

    I think moving forward, iOS8's WKWebView is a godsend for C2 games because its just so damn fast and low memory. Android we're stuck with sub-optimal options for a long time yet.

    Edit: I did notice an improvement in smoothness when I switched my Android devices over to ART (was Dalvik). That's a good sign since Android 5+ is on ART.

  • Silverforce on YouTube movie I see smooth movement, on Android (even when I switched to ART) I see jumpy movement. I guess that many players think that it's the way it should be (because your game has nice, old school feeling). Anyway: how do you use WKWebView? Compile game with PhoneGap?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Silverforce on YouTube movie I see smooth movement, on Android (even when I switched to ART) I see jumpy movement. I guess that many players think that it's the way it should be (because your game has nice, old school feeling). Anyway: how do you use WKWebView? Compile game with PhoneGap?

    Phonegap doesn't support wkwebview for now, they have some kind of a plugin for a local webserver to run wkwebview and some other plugins, but only in pre-alpha versions, they are waiting for a fix of a bug where wkwebview can't load local files. Ludei webview+ is a wkwebview, works damn good, but i heard that saveload and webstorage can be cleared there randomly.

  • Sisyphus

    PhoneGap is not ready, but Ludei webview+ is almost ready?

    so it will be perfect when webstorage issue will be fixed and we will have possibility to use native AdMob

    btw.

    About Android: I have just found some blog post from the end of the 2013.

    "The KitKat WebView is based on Chromium 30 and it won’t be updated. That means you are stuck with it unless to get an upgrade in the future of the whole OS to next version. Even Google has announced OS delta updates without vendors’ intervention, but it seems the WebView will not get that deal yet. Therefore and based on Chrome release cycle, in one year we will have Chrome 40 and the WebView will still be in 30."

  • Silverforce on YouTube movie I see smooth movement, on Android (even when I switched to ART) I see jumpy movement. I guess that many players think that it's the way it should be (because your game has nice, old school feeling). Anyway: how do you use WKWebView? Compile game with PhoneGap?

    What devices have you tested it on? I have Nexus 7 2013, Samsung S4 mobile, LG G-Pad 8.3 and a few others, its all pretty smooth after a short period of slight stutter on load.

    CJS WebView+ on version 2.1+ is for iOS8's WKWebView, and its smooth as you see it in the youtube video while only using 15-20% of the iPad Mini 2's CPU.

    Android's Webview is horrible so forget about it for serious games. We're stuck with Crosswalk or CJS Canvas+ for awhile yet, since Android 5 rollout is slow.

  • About Android: I have just found some blog post from the end of the 2013.

    "The KitKat WebView is based on Chromium 30 and it won’t be updated. That means you are stuck with it unless to get an upgrade in the future of the whole OS to next version. Even Google has announced OS delta updates without vendors’ intervention, but it seems the WebView will not get that deal yet. Therefore and based on Chrome release cycle, in one year we will have Chrome 40 and the WebView will still be in 30."

    Only android 5.0 and greater can get updates of webview from google play, wait for a year or 2, now there's no hope for android's webview.

  • Silverforce

    I have tested SNE on Alcatel One Touch Flash, so octa core MTK + 1 GB RAM [ ]. And now I was playing for 4-5 minutes and it was still hmm... I guess 60 fps but jumpy spaceships movement, jumpy planets rotation etc. Anyway it's good to know that at least iOS runs very good. So nevermind. Just FYI

    Sisyphus

    so now I'm waiting for fixed Crosswalk and/or native AdMob in CocoonJS Canvas+.

  • [quote:ceyy7t2h]Silverforce

    I just bought Star Nomad on iOS. Cool game, nice work! But still.. there is a micro-pauses. It's not a FPS failure - FPS is fine. If you look closely you'll find these small pauses. The gameplay is not smooth For me, it does matter. This little thing can separates bad game from good game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)