How to reduce the number of crashes (mobile)

Discussion and feedback on Construct 2

Post » Wed Mar 11, 2015 9:54 pm

Hi,

My mobile game runs nicely on Android (not many crashes), but on iOS, especially when exported with Phonegap Build, I have too many crashes! Even on an iPad Mini 2. Is there any precise tips to try to reduce the number of crashes? Should I delete as many images as possible, or should I rather try to deactivate as many event groups as possible, or something else?

I found this thread on the topic, with a reply by Ashley :
what-is-the-best-practice-to-track-crashes-on-mobile_p848185?#p848185

Ashley wrote:Crashes (as in the app exits) are usually caused by buggy graphics drivers, or running out of memory. In rare cases it may be a browser bug, but the first two causes are far more likely. There's not much you can do about buggy drivers; most mobile platforms don't allow updates outside of updating the entire OS, which is subject to the carrier/manufacturer approving the update.

If there's a bug in the C2 engine then if the JS code goes wrong it probably won't crash the app. It will probably freeze instead, since the browser engine catches the JS error, halts the script, and then continues running the page. That's useful in web pages but since the C2 engine is all JS then the game logic halts freezing the game then the last frame remains on-screen. If that happens then ideally you'd be able to reproduce it and report it as a bug to us so we can fix it.


My problem is probably memory, as my game runs mostly on only one layout.

Thanks!
B
19
S
5
G
1
Posts: 301
Reputation: 2,192

Post » Wed Mar 11, 2015 10:23 pm

The dirty little secret with Apple devices is that their specs are often very underwhelming vs their cost; case in point, no iPad or iPhone (except for the iPad Air 2) has more than 1GB of memory, the same amount I have in my $20 android phone. Most decent androids have 2GB now, and flagships usually have 3GB.

iOS doesn't have as bloated a footprint as android, which is part of why it runs so well, but that still leaves you with precious little memory. In combo with being a 1 layout game, you're playing with fire. What is your estimated footprint for your project in C2? If it's over 250MB, I'd be worried.

@silverforce might be able to give some guidance too; I wonder how much memory Star Nomad uses?
Don't lose your work. Backup your game with Dropbox.
B
43
S
10
G
10
Posts: 1,106
Reputation: 9,157

Post » Wed Mar 11, 2015 10:41 pm

I don't have exp with PhoneGap so I can't comment to this specific crash.

I used CJS WebView+ which ran on WKWebView (requires iOS 8+) on iOS with enhanced memory usage and performance. I don't know if PhoneGap uses that or just the default system WebView, which actually suck a lot for C2 games that are complex.
B
67
S
24
G
19
Posts: 1,754
Reputation: 17,526

Post » Thu Mar 12, 2015 10:36 am

Given memory use is probably the most likely cause, what is the memory use of the game that is crashing as measured by C2? (It estimates it in the editor status bar, or you can view it from the debugger.)
Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,157

Post » Thu Mar 12, 2015 1:04 pm

@TiAm I'm unaware of what a footprint is (sorry). But I guess it's what Ashley is asking for in his reply?

@Ashley The C2 editor tells me "Memory use : 298.2 mb"

When playing the game in Debug mode, memory usage (images) goes sometimes higher than 100Mb. Sometimes even higher than 120Mb if the player wanders on the map... :-(
From what I experienced, on an iPad mini 2, the game seems to crash as soon as the memory use is above 100Mb, which is quite problematic.

What I noticed is that even if I delete the objects, they are not erased from memory. Actually the game only refreshes memory when changing layout.

Is there any way to refresh memory other than changing layout?
Otherwise, separating the map on a different layout seem to be mandatory.
Any other tip?

Thanks a lot!
B
19
S
5
G
1
Posts: 301
Reputation: 2,192

Post » Thu Mar 12, 2015 3:37 pm

An iPad Mini 2 apparently has 1 GB RAM, so it should be fine with that much... but still, 300mb estimated memory for a mobile device is quite a lot, perhaps the tips in Remember not to waste your memory will help.
Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,157

Post » Thu Mar 12, 2015 4:01 pm

Oh, I actually forgot something important! This test was done on my PC, using the uncompressed images, but each time I export Healer Quest, I replace all the images with their compressed version in the image folder. I think the image folder's size drops from 50+ Mb to 16 Mb! So the actual memory usage is probably less than what is displayed in the editor and debug mode. So it should be still better than what I told in my previous post.

Still, the game crashes a lot ! :(

Thanks Ashley, I remember reading this post a few month ago, but I'll read it again.

EDIT : Have read it and it contains the info I was looking for :

"In Construct 2, images are loaded layout-by-layout. This means when a layout starts, every object on the layout is loaded in to memory immediately. This is to avoid mid-game pauses as textures are loaded on the fly. When the layout ends, it will free all the images in memory not used by the next layout, and load any new images the next layout uses."

So I'll definitely try to put my map on a separate layout if possible.
B
19
S
5
G
1
Posts: 301
Reputation: 2,192

Post » Thu Mar 12, 2015 11:10 pm

Doesn't make any difference if you compress the images (this only reduces the app size on download & installed), art gets loaded into vram as raw textures.

C2 underestimates memory use in the editor because that assumes a few key factors which may not apply to mobiles.

The first thing is you need to figure out: is PhoneGap using the system WebView on iOS? If so, forget-about making complex games with lots of art assets and using PhoneGap. Just forget about it. iOS hates games that use above 100MB of memory and definitely anything 200MB+ is asking for repeated crashes. Do not forget that our testing devices are quite clean, user devices are bloated with many many apps running in the background.

You need to use iOS8+ improved WKWebView if you have a complex game.
B
67
S
24
G
19
Posts: 1,754
Reputation: 17,526

Post » Thu Mar 12, 2015 11:21 pm

Rable wrote:@TiAm I'm unaware of what a footprint is (sorry). But I guess it's what Ashley is asking for in his reply?


I'd like to know what footprint is too. :D
B
52
S
21
G
3
Posts: 599
Reputation: 6,506

Post » Fri Mar 13, 2015 11:07 am

See 'Common misconceptions' in Performance tips:

Image formats (e.g. JPEG, PNG-8, PNG-32) affect the download size but have no effect on runtime performance or memory use (they are all decompressed to 32-bit bitmap on startup).


In other words, the image file size/format has no effect on memory use. It's effectively decompressed and loaded in to memory as a 32-bit ARGB bitmap.
Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,157

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests