Marmalade Tricks and Tips

During the days to develop our first game: Day Day Birds, I went through the progress of learning to use Marmalade, generally it’s very easy to use, and save me lot of time, though there are some little things that I hoped that I know earlier.

Stack Size

The game started to crash randomly before I noticed, it’s quite hard to debug, especially without the tools in Xcode or other IDEs provide. And it never crash in the simulator, so the debugging is quite awkward, a lot of guess, build, test-run going on.

When it crashed on iOS device, some information were provided, though full stack trace is not availabe, and the place of crash is not consistent. After 2 or 3 days and nights figihting with this bug, finally found out the root cause, which is very surprising.

It’s caused by stack overflow, since Marmalade is designed to support many different mobile devices, many of them are with limited hardware, the stack size is 32k by default, since I’m having a LUA layer, and also allocated some string buffer in stack for convinience, it got overflowed, so caused the random crash.

There is actually a forum thread mentioned this.

Since I only plan to support the modern devices (iPhone, iPad, maybe Android as well), gave it a much bigger setting fix the crash perfectly.


Accelerate framework

I’m using libBass for the audio playpack, for some reason it require Accelarate frame under iOS to compile. so I add iphone-link-opts="-weak_framework Accelerate" into the mkf file.

For unknown reason, the Accelerate.framework stub in /Developer/Marmalade/6.2/s3e/deploy/plugins/iphone/sys_libs/System/Library/Frameworks/Accelerate.frameworks/Accelerate is not working, might be the nested frameworks inside it.

Not really understand how the stub frameworks work in Marmalade, seems a smart way to use the system’s SDK libraries, though a hacky solution make it compiled.

Current fix is to copy the framework from /Applications/ Not sure whether there is side effects.

cp -r /Applications/* /Developer/Marmalade/6.2/s3e/deploy/plugins/iphone/sys_libs/System/Library/Frameworks/Accelerate.framework/

iOS device crash report

This page explains how to read the crash report nicely, also don’t forget to save the mapping file of the version you submitted to app store, otherwise you will have no idea to debug when get crash logs from Apple.

How to map iPhone crash log addressed to your code

Some mkb settings



iphone-enable-4inch-retina=1 enabled the iPhone 5 wide screen mode.

Some app.icf settings


{ID=IPHONE "iPad1,1"}
memSize = 30000000
{ID=IPHONE "iPad2,1","iPad2,2","iPad2,3","iPad2,4","iPad2,5","iPad2,6","iPad2,7"}
memSize = 64000000
{ID=IPHONE "iPod1,1","iPod2,1","iPod3,1","iPod4,1","iPhone1,1","iPhone1,2","iPhone2,1"}
memSize = 34000000
{ID=IPHONE "iPod5,1","iPhone3,1","iPhone3,2","iPhone4,1","iPhone4,2"}
memSize = 64000000
memSize = 80000000
memSize = 256000000

DispFixRot="Landscape" is to lock the screen rotation to be landscape only, I’ve met quite some problem with landscape, probably will write another post about it.

IOSDispScaleFactor=200 is used to activate the retina screen support, so the resolution of retina iPad will be 2048 x 1536,

It took me quite some efforts to learn how to do the device-specific settings in app.icf, the syntax is quite complex, the marmalade documents actually cover this, though lacking good samples.

comments powered by Disqus