SOLVED: CocoonJS game crashes on device sleep

  • Is this a common problem for Construct 2 apps compiled by CocoonJS for android?

    I've tested this on several devices, if the game is running, the the device is left on for awhile to naturally go to sleepmode, upon wakeup, the game crashes, and have to be restarted several times for it to work.

    I've tried digging for info on this, just want to know if this is a known issue or its something unique to my game, which is pretty big, around 40MB all up.

  • We now recommend using Crosswalk instead of CocoonJS for Android. Try using that instead.

  • Crosswalk is non viable until it reduces overhead, adding 20MB to your project into the APK is a sin when we are working with 50MB limits.

    Anyway to add something like?:

    public static final int PARTIAL_WAKE_LOCK

    Allowing screen to black out but CPU keeps game active, upon resume it should resume as normal.

    Edit: I found a var in the runtime on C2 cocoon export, autolock, its set to enable, allowing the device to go into sleep mode on a period of inactivity. I have changed this to disabled, and compiling it again to test. Fingers crossed.

    Edit2: It works. Ingame, the device will not go to sleep mode.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Silverforce

    Wow! That is really interesting and useful information! Thanks!!

  • To be specific, this is the line you want in Runtime.jscript

    CocoonJS.App.setAutoLockEnabled = function (enabled)

    Just change it to disabled and it works very well.

    I just noticed the new Cocoon builder, ingame, if users press Home on their device, it now suspend the game and goes to device screen and can resume instantly when they switch back. The old build, pressing Home would close the game, switching back restart it from ludei loading logo. So its a great improvement.

    Testing the new WebGL screencanvas option with the latest C2 build and CocoonJS. Will update progress.

  • To be specific, this is the line you want in Runtime.jscript

    CocoonJS.App.setAutoLockEnabled = function (enabled)

    Just change it to disabled and it works very well.

    I just noticed the new Cocoon builder, ingame, if users press Home on their device, it now suspend the game and goes to device screen and can resume instantly when they switch back. The old build, pressing Home would close the game, switching back restart it from ludei loading logo. So its a great improvement.

    Testing the new WebGL screencanvas option with the latest C2 build and CocoonJS. Will update progress.

    @Silverforce thank you for this solution. It works great. My apps were getting rejected from the Amazon app store for the same reason, it would be nice if there was an option in Construct 2 to enable or disable that setting so we didn't have to edit every build

    EDIT: looks like maybe this didn't fix my problem... it's still crashing after device wakes up

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