Performance is very bad on android devices

Performance is very bad on android devices
0.0 0



i’m developing an application with many objects (1000) with chipmunk on iOs devices the performance is good (iPad2 35fps, iPodTouch 4.gen 15fps). But on android Galaxy S2 it gets only up to 10 fps with only 500 objects with 1000 it doesn’t work. Are there any compile params i can use to get much better performance? How can the code optimized to get a good performance on android?
setup physics:
m_pSpace->gravity = cpv(0, 100); m_pSpace->sleepTimeThreshold = 0.5f; cpSpaceSetIterations(m_pSpace,10); cpSpaceUseSpatialHash(m_pSpace, 14.0, 10000);

generating the objects in a for loop:
float mass = 1.0 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(3.0-1.0))); float radius = 4.0f + mass; cpBody *ballBody = cpBodyNew(mass, cpMomentForCircle(mass, radius, radius, cpvzero)); cpBodySetVelLimit(ballBody, 150.0f); cpBodySetPos(ballBody, cpv(pos.x, pos.y)); cpSpaceAddBody(m_pSpace, ballBody); cpShape *ballShape = cpCircleShapeNew(ballBody, radius, cpvzero); ballShape->e = 0.0; ballShape->u = 0.0; cpSpaceAddShape(m_pSpace, ballShape);

Best regards,


What settings do you have in your JNI?

Mine is full of the things I moved over from XCode


Thank you for the tip with the settings. I added armeabi-v7a and now it runs good.
My is now:
APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 LOCAL_CFLAGS := -ffast-math -O3 -funroll-loops APP_ABI := armeabi armeabi-v7a
Are there any other params to increase the performance?


Try disabling debug mode using APP_OPTIM := release and comment out debug flag -DCOCOS2D_DEBUG=1


To explain release, look in android-ndk-r8e/build/core/

ifeq ($(APP_OPTIM),debug)
So, to answer your question: in NDK r8b (the latest for today) you can check

#ifdef NDEBUG
// this is "release"
// this is "debug"