Program received signal: “0”.

Monkey Targets Forums/iOS/Program received signal: “0”.

therevills(Posted 2011) [#1]
Finally got Pirates running on the iPod... (after fighting with Apple to get the dev program, installing certificates and finding out how to change the architecture to arm6 etc)

But after playing the game for a few minutes it crashes (works fine in the simulator)... found the debug console (why gdb??) and it out puts the following:



Any ideas?

Thanks!


anawiki(Posted 2011) [#2]
Something wrong with sound?

Anyway, congrats on getting through the pain of setting up certificates :) I'm still not done with that...


xzess(Posted 2011) [#3]
yeah finally me got it running also.
I have a memory warning also, is there a possibility to free memory?


marksibly(Posted 2011) [#4]
Hi,

Are you loading images while the app runs, or preloading all images at startup?


therevills(Posted 2011) [#5]
Most are preloaded at the start (along with all the sounds, apart from Music), the backgrounds are loaded per level... one level contains 10 rounds and it only loads the background on round one.

Ive seen the crash happen when just playing the cards (nothing special happening) and when the next round starts.


marksibly(Posted 2011) [#6]
Hi,

How about music? How many songs are there?

The current version does have issues with auto-releasing images though.

I'm gonna add a Discard() method to Image and Sound, but you should still be able to rely on GC (once I fix it!).


therevills(Posted 2011) [#7]
The music is played via the PlayMusic command at the start of each level. I think there are 8 tracks (1 for the intro, 1 for the title and 6 for the main game).


The current version does have issues with auto-releasing images though.



Cool Ill hold off releasing anything on the iOS for now... any eta?


xzess(Posted 2011) [#8]
Thanks mark, this sounds great!
Best wishes


xzess(Posted 2011) [#9]
Im really hot on that Discard() method, hopefully you can add it in the next version because my workaround isn't really nice and i want to release it in appstore when you add the Discard() method (if it don't take to long)

Mark, could you give a date over thumb?

Unfortunately i have the same problems like therevills :/


therevills(Posted 2011) [#10]
Just tested v40... still getting this error.

Ive removed the PlayMusic command and it does play better... for a while, then I get the error again...


marksibly(Posted 2011) [#11]
Hi,

Can you email me the project?


therevills(Posted 2011) [#12]
Will do... its around 25MB though.

Been testing some more... Ive removed the PlaySounds now, but it still crashes. If I leave the game alone (on the game screen) it sometimes crashes as well.

BTW Im using XCode 3.2.6 if it makes a difference.


anawiki(Posted 2011) [#13]
We're getting that error too :(

Maybe it's because we try to play another song? On the title screen the music plays well, but when we move to the game it should play different song and so it crashes.

If we remove music from the game it works like a charm.


therevills(Posted 2011) [#14]
I tried removing the music too and it latest longer, but still got the error later on.

I've been emailing Mark about this issue:


Well, I don't think it's a memory leak - I just ran it through a leak
detector thing in xcode which only came up with one leak in mac audio
(per run) which is apparently known about:

http://stackoverflow.com/questions/3837294/iphone-openal-audiotoolbox-leak

If you want to test for leaks yourself, run
'/Developer/Applications/instruments', choose 'leaks' at startup, then
'MoneyGame' from the 'Choose Target' combo and the 'record' button to
start recording. Game already needs to be uploaded to device.

I added a little 'max mem usage' monitor to the built-in Monkey GC,
and it never even reaches 1Meg so it doesn't appear to be anything
language related.

But in the instruments tool, it says the app is consistently using
30M, and occasionally spikes at 50M. This is non-Monkey overhead, and
I'm not sure why it's so big but I'm guessing it's graphics related.

Okay...it does appear to be graphics related - GLES texture memory is
at about 30M according to the 'Graphics' instrument.

I think what you'll need to do is:

* Remove alpha from any images that don't require it - had a quick
look and all your images appear to include alpha.

* Aggressively use Discard() to discard images when they're not needed.

* Use the attached mojo.ios.cpp - doesn't seem to make a difference
here, but it does contain one 'recommended' tweak that pertains to
memory management.




In mojo.ios.cpp, change this...

UIImage *uiimage=[ UIImage imageNamed:nspath ];

...to this...

UIImage *uiimage=[UIImage imageWithContentsOfFile:nspath];




Oops, use this instead:

UIImage *uiimage=[UIImage imageWithContentsOfFile:[[NSBundle
mainBundle] pathForResource:nspath ofType:nil inDirectory:@""] ];

I reckon try that + discards - it might be enough!




Also did you see what Skid wrote in the rendering performance thread about Cls?

http://www.monkeycoder.co.nz/Community/post.php?topic=869&post=7399

I havent used Cls in PS as I thought it would be slower and not needed, but going on the doco about Erase the Renderbuffers it might help with the Program received signal: “0” crash.

I havent had time to test these, hopefully on the weekend...


therevills(Posted 2011) [#15]
Just tried the "fix" to mojo.ios.cpp, and it didnt work... now if I turn off music and sound it seems pretty stable...

@anawiki - what sound format are you using?

[Edit]
Just swapped my sounds from WAVs to MP3s and it looks stable with sounds on and music off... (also looks like V40 has fixed the popping sound with mp3s)
[/Edit]


therevills(Posted 2011) [#16]
More testing...

Ive got 6 music files which I play during the main game with the PlayMusic command, for iOS they are MP3s.

Track | Memory Warning | Crash | Size
------+----------------+-------+--------
   0  |     YES        | YES   | 1.1 MB
   1  |     NO         | YES   | 1.4 MB
   2  |     NO         | YES   | 1.5 MB
   3  |     YES        | YES   | 1.0 MB
   4  |     NO         | NO    | 709 KB
   5  |     NO         | YES   | 1.7 MB


This is with the "fix". So looking at these results it looks like anything over 1MB crashes the game... BTW the game plays an intro with music of 250KB, then displays the title with music of 1.2MB.

Im going to compress the music under 1MB to see if this helps...

[Edit]
Track | Memory Warning | Crash | Size
------+----------------+-------+--------
   0  |     YES        | NO    | 803 MB
   1  |     NO         | YES   | 1 MB
   2  |     NO         | YES   | 1.1 MB
   3  |     NO         | NO    | 774 MB
   4  |     YES        | NO    | 532 KB
   5  |     NO         | YES   | 1.3 MB



anawiki(Posted 2011) [#17]
I am using m4a format. Don't remember the size of files at the moment, but I believe that the title song is bigger than 1mb and it plays fine. The game crashes later when we try to play another song. I am using v40.


therevills(Posted 2011) [#18]
So you are purely using m4a for all files (music and sounds)?


therevills(Posted 2011) [#19]
Compressed the tracks to 24000Hz, 24kbps, mono

Track | Memory Warning | Crash | Size
------+----------------+-------+--------
   0  |     N          | N     | 406 KB
   1  |     N          | N     | 520 KB
   2  |     N          | N     | 553 KB
   3  |     N          | N     | 389 KB
   4  |     N          | N     | 270 KB
   5  |     Y          | N     | 635 KB


I've emailed Mark my results and this is his reply:

Hi,

The music in the iOS version isn't streaming yet, so it will consume a
lot of memory - any idea how long the music is uncompressed?

Will have a look into streaming music for iOS early next week.

Bye!
Mark



[edit]
Just played an entire level (10 hands) of Pirates Solitaire with the above music files on the iPod, which took over tens minutes - it didnt crash and started the next level fine :)


anawiki(Posted 2011) [#20]
I'm using w4a for almost all music and sounds, except one sound effect that after converting to m4a made the game crash (so I keep it in wav).

My music is 1.2MB size in w4a and 12MB uncompressed and plays fine. The one that fails is 2.2MB size in w4a and 19MB uncompressed.