SOLVED: CocoonJS game crashes on device sleep

Discussion and feedback on Construct 2

Post » Tue Jan 14, 2014 11:29 am

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.Silverforce2014-01-16 03:23:58
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Tue Jan 14, 2014 2:30 pm

We now recommend using Crosswalk instead of CocoonJS for Android. Try using that instead.Ashley2014-01-14 14:30:39
Scirra Founder
B
402
S
238
G
89
Posts: 24,618
Reputation: 196,003

Post » Tue Jan 14, 2014 10:17 pm

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. Silverforce2014-01-15 00:02:39
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Wed Jan 15, 2014 6:19 am

@Silverforce

Wow! That is really interesting and useful information! Thanks!!
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Thu Jan 16, 2014 3:11 am

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.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Thu Feb 20, 2014 6:44 pm

Silverforce wrote: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
B
64
S
12
G
6
Posts: 456
Reputation: 9,015


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests