too slow for android 4.0.x and 4.1

Hello,
Too slow for android 4.0.x (ice cream sandwich) and 4.1

Test)
same code, same hardware spec, 2 devices
game’s fps is good for android 2.3.6
but, android 4.0.x or 4.1 is too slow sometimes(schedule and animate is canceled sometimes)

I think this issue is not depends on device,
maybe depends on android OS or cocos2d-x

I’m using cocos2d-x 2.0.2

It is so strangely…

Do you have any clue?

+1 for that issue

A port of alpha version of my iOS game has strong 60 fps on HTC Wildfire S with Android 2.3.5, while on GALAXY SIII with Android 4.0 - only 40 fps. I’m not sure if this can affect performance, but when creating android project I set the target to Android 4.0. Currently the game is not heavy on graphics, so most likely it will drop to unacceptable 20-25 fps with more sprites/effects on screen.

Any ideas/fixes?

Minggo Zhang wrote:

Do you have any clue?

You can test “Zwoptext Tests”

You can see http://youtu.be/4oowC9fA-bk

  1. First phone is galaxyS1(2.3.6)
  • it’s smooth when right button touched
  1. Second phone is galaxyS2HD(4.0.3)
  • it’s drop framerate when right button touched. Look at the framerate.

I think file I/O performance or security issue between cocos2d-x and android OS 4.0.x or above.

Victor Komarov wrote:

+1 for that issue
>
A port of alpha version of my iOS game has strong 60 fps on HTC Wildfire S with Android 2.3.5, while on GALAXY SIII with Android 4.0 - only 40 fps. I’m not sure if this can affect performance, but when creating android project I set the target to Android 4.0. Currently the game is not heavy on graphics, so most likely it will drop to unacceptable 20-25 fps with more sprites/effects on screen.
>
Any ideas/fixes?

in my case,
add option “APP_ABI := armeabi armeabi-v7a” to Application.mk, and build_native~
You can see increase framerate, but It is just little more,

Victor Komarov wrote:

A port of alpha version of my iOS game has strong 60 fps on HTC Wildfire S with Android 2.3.5, while on GALAXY SIII with Android 4.0 - only 40 fps. I’m not sure if this can affect performance, but when creating android project I set the target to Android 4.0. Currently the game is not heavy on graphics, so most likely it will drop to unacceptable 20-25 fps with more sprites/effects on screen.

I have ported my game Arrow Mania to an S3, running Android 4.0.4 at the moment, using “cocos2d-2.0-x-2.0.2 @Aug.30 2012”. It has no problems running at 60fps and there is quite a lot on screen. See my video https://www.youtube.com/watch?v=f4oDq-wLUsw

One thing maybe to note, turn off “power saving” mode on the phone.

GavT GMTDev, I’m using the latest stable version, maybe the problem is here.

Btw, what target did you set for your app? did you make any changes to android.mk?

hermes shin wrote:

Minggo Zhang wrote:
> Do you have any clue?
>
You can test “Zwoptext Tests”
>
You can see http://youtu.be/4oowC9fA-bk

  1. First phone is galaxyS1(2.3.6)
  • it’s smooth when right button touched
  1. Second phone is galaxyS2HD(4.0.3)
  • it’s drop framerate when right button touched. Look at the framerate.
    >
    I think file I/O performance or security issue between cocos2d-x and android OS 4.0.x or above.

I found something,

Same code, Same files, test 2 devices

  1. GalaxyS1 (2.3.6)
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“zwoptex/grossini.plist”);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“zwoptex/grossini-generic.plist”);
    elapsed time : 0.076

  2. GalaxyS2HD (4.0.3)
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“zwoptex/grossini.plist”);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“zwoptex/grossini-generic.plist”);
    elapsed time : 0.180

Maybe some power saving option is on?
Also, did you try commenting the Sleep when rendering frames?

Victor Komarov wrote:

GavT GMTDev, I’m using the latest stable version, maybe the problem is here.
>
Btw, what target did you set for your app? did you make any changes to android.mk?

Oh right my mistake, I can confirm there is a problem. If I set the project build target in Eclipse to Android 4.0.3 the frame rate drops to 54fps, Android 2.2 and its >60fps. And I didn’t recompile the code in terminal, just build (link) and run in Eclipse.

Power save option was on, hehe. Without it everything is fine (stable 60 fps).

Oren Bengigi wrote:

Maybe some power saving option is on?
Also, did you try commenting the Sleep when rendering frames?

Power saving option is off,
also, Cocos2dRenderer.java
// Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND);

Try disabling HW acceleration. Maybe it is related too…

Oren Bengigi wrote:

Try disabling HW acceleration. Maybe it is related too…

“Force GPU rendering” is off
“System power saving” is off
“Custom power saving” is off
just “USB debugging” on.

No,
You need to disable it in the manifest.

See here how to do it:
http://developer.android.com/guide/topics/graphics/hardware-accel.html

Let us know if that works.

Oren Bengigi wrote:

No,
You need to disable it in the manifest.
>
See here how to do it:
http://developer.android.com/guide/topics/graphics/hardware-accel.html
>
Let us know if that works.

Yeah that is it. I added “android:hardwareAccelerated=”true" in my manifest and with target set to 4.0.4 the game is back to 60fps+.

e.g.

GavT GMTDev wrote:

Oren Bengigi wrote:
> No,
> You need to disable it in the manifest.
>
> See here how to do it:
> http://developer.android.com/guide/topics/graphics/hardware-accel.html
>
> Let us know if that works.
>
Yeah that is it. I added “android:hardwareAccelerated=”true" in my manifest and with target set to 4.0.4 the game is back to 60fps+.
>
e.g.
>
[…]

It is not works for my case.
(I set android:hardwareAccelerated=true, and target set to 4.1.2, and run… Same result)

I drill down bottleneck.

CCSpriteFrameCache, addSpriteFramesWithFile
CCSAXParser
CCFileUtils.cpp
CCFileUtils::getFileData
CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize);

last line is consuming 0.08~ 0.12 on 4.0.3
but 0.004~0.016 on 2.3.6

now, I drill down unzip.cpp…

Oren Bengigi wrote:

No,
You need to disable it in the manifest.
>
See here how to do it:
http://developer.android.com/guide/topics/graphics/hardware-accel.html
>
Let us know if that works.

doesn’t work.

freezing fps when read plist file on android 4.0.4 or above

2.3.6 : 7~8.8 fps
4.0.4: 2.4~2.7 fps

I test samples which Zwoptex tests in cocos2d-x

and I test some more for cocos2d-x 1.0.1, 0.12.0
2.3.6: 29~38 fps
4.0.4: 22~35 fps
It is little difference cocos2d-x 2.0.2
What diff cocos2d-x 1.0.1 and 2.0.2 about read plist?

I have met the same problem as you.
Have you solved the problem?

wk J wrote:

I have met the same problem as you.
Have you solved the problem?

Please refer to the Pull Request https://github.com/cocos2d/cocos2d-x/pull/1680 .
Could you apply that changes and check whether it works?