-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android rendering performance issue #15652
Comments
Run |
I have the performance issues on my game and it appears to be something to do with SimpleAudioEngine? My game makes a sound every time you tap the screen. When tapping the screen on an Android 6 device, the game stutters quite badly. I found that disabling the sound effects (but leaving the background music playing) stops all stuttering and the game runs at a smooth 60fps. Cocos2D-X 3.10 The game works fine on my Android 5.1 Amazon Fire tablet, which is a much lower spec device. |
@PorkyPixels Thanks for your information. Why not use new Audio engine? It uses OpenSL and have good performance. |
@minggo one reason could be it is still "experimental" |
@minggo I use SimpleAudioEngine as I'm familiar with it and never had a problem with it before. Thanks for the suggestion though, I will look into the the new audio engine and see if that resolves the issues on Android 6. |
@larsven the only reason that it is named |
@minggo ok thanks for the info |
I started developing an infinite runner game last year, starting with Cocos2d-x 3.6 and I've been updating the cocos version up to 3.9 (and not further because I stopped developing the game for now, but I plan to work on finishing it soon). It has always performed great on iOS devices (even on an old iPhone 4), but Android has always been some steps behind. From my experience, Android devices can also reach 60 FPS but they generally are less constant, with some random lagging. And there's the audio problem (both with SimpleAudio and experimental, although experimental seems to perform better): Sometimes when I play a sound, there's a noticeable lag (FPS slightly drop for an instant). Let's be more concrete: All the following tests were made with a build of my game with Cocos2d-x v3.9 (I didn't notice big differences in performance from 3.6, 3.7 or 3.8, so that's why I'm only sharing 3.9 results)
Also, testing older and less capable Android devices I was surprised to discover that the game got very low FPS on some Samsung devices while it ran decently well on an older one. See:
http://www.gsmarena.com/compare.php3?idPhone1=3725&&idPhone2=6190&idPhone3=5422 Also tried on a Motorola Moto G (1) and it achieved 60 FPS with Android 4, same small FPS drops when playing sounds as the LG G3. Similar behavior with a Nexus 4 with Android 5. I hope this helps! And if there's anything I can test with the devices I still own, just tell me (Samsung Galaxy mini, LG G3, iPhone 4, iPod Touch 6th gen, iPad mini) and I'll try if I can. |
@iPruch thanks for the detail information. It seems it is Android OS version and Android device related. What i can find is that the audio engine will affect performance issue on all situations. I found Android provide high performance Audio, hope it is so high performanne as it says. Edit: AudioEngine already uses OpenSL ES. |
@iPruch could you please update |
@minggo I don't think that such an old device can officially update that far, and also I wanted to keep it with 2.3.6 to have an old Android device to test. Maybe an Android 6 ROM can be flashed, but I've never done that before and I don't know the process and risks. I'll take a look |
@iPruch I found the specification of Samsung Galaxy mini (S5570) and Samsung Galaxy Tab 3 (7.0). It seems S5570 has more powerful of CPU and less powerful of GPU:
So may be the bottleneck is on CPU? Could you please use NDK profiler to have a try? |
@minggo No, that is not the Samsung Galaxy mini S5570. This is it: http://www.gsmarena.com/samsung_galaxy_mini_s5570-3725.php Much older and powerless: Just 1 core @ 600 MHz and Adreno 200 GPU |
Oh, its resolution is 240 x 320 pixels (~127 ppi pixel density), so it is GPU related. |
Because cocos2d-x is a 2d game, almost all objects are drawn in the same layer(the z is 0), so the overlap issue is more serious because z-test has not effect. |
@minggo But what I was saying on my first and long post above is that the S5570 performance is good (around 45 FPS) considering the lack of power of the device, and other devices as the Tab 3 only achieve around 20 FPS being more powerful. I think sometime ago I saw a thread on the Cocos2d-x forum about the bad performance in some Samsung devices being fault of Samsung's custom implementations of some Android core parts. I'll post it here if I find the thread |
Yep, because S5570's resolution is much lower than Galaxy Tab 3. |
@minggo Ok, I didn't understand you at first. |
Maybe the Samsung devices low FPS problem is due to the power saving mode? http://stackoverflow.com/a/17670350 It's a shame that I can't test it with those Tab 3 and S III mini because I don't have them anymore. |
I'm experiencing a similar issue (Cocos2d-x 3.10) I'm showing a Scene, and tested on these two Android phones:
On the Nexus 5x, I get an FPS of 11-13. Same APK, same Scene, same resolution. The scene has about 165 sprites. No sound is used anywhere. No labels are used. I haven't activated any kind of power saving modes. I'm using the following Node types: Layer (as a base of the Scene) |
@niekvse Thanks. Could you share the codes? I can find Nexus 5 to test, but i don't have Nexus 5x. |
@minggo I wanted to add that I tried the same thing with lower resolution sprites (the same sprites but for a lower res phone), and it was just as slow. But it seems to be related to Sprites: when I remove them and replace them with DrawNodes (simple square of the same dimensions), it's 60 FPS instead of 12 FPS. and I also ran the App Tune-up Kit from Qualcomm to see if the bottleneck is CPU or GPU bound for this app. Testing the same APK on the Nexus 5x, this tool tells me it's a CPU-bound issue. I wouldn't fully trust this simple tool however, but maybe it can help. I also tried the same APK on a Galaxy S6 with Android 6.0.1, and on that one it was fast (60 FPS). So somehow on the Nexus 5x (which is otherwise a very fast phone) the FPS is very low. I can share the project but I'm not sure you can reproduce the same on a Nexus 5, because this is quite a different device (I don't have one, so I couldn't try). Is it ok if I mail it to you? Still - I wouldn't be surprised if many Cocos games suffer from this on the 5x (and probably other phones) because I'm only doing some very basic things. No animation, just displaying static sprites. |
@niekvse thanks for testing. It is ok to mail me, thanks. I have test it on Nexus 5. |
@minggo I sent you the entire project (360MB or so) by wetransfer. You should get the email shortly. The big size is from Cocos - the actual code is only a few lines - but I thought it would be best to send everything, so you can reproduce it as accurately as possible. Please DO NOT distribute this project anywhere online. Let me know if you have any questions! I included screenshots of the app running on the Nexus 5x and on the HTC ONE M7, so you can see the different FPS numbers in the corner. If you find out the cause of the issue - I'd love to hear it! Thanks! |
@minggo I solved the issue by more strategically adding my Nodes (I'm new to Cocos so I wasn't aware of the details of the batch algorithms). This does not completely explain why it was fast on the much older phone, but I have an idea. I had 80 sprites and 80 drawnodes (background boxes), each drawnode containing one sprite (so they could be scaled and moved together, etc.) Apparently this meant that the sprite batching did not work, so the OpenGL calls were done like this: draw square 0 -> draw sprite 0 -> draw square 1 -> draw sprite 1, etc. By first adding all DrawNodes and then adding all Sprites, all sprites could be batched, resulting in an FPS of 60 on the Nexus 5x. So my conclusion is that the Nexus 5x somehow has a much higher overhead for the individual sprite draw calls than the older HTC (does it have to reload the texture each time? I wouldn't think so as I'm using a SpriteFrame). So, the question remains why the OpenGL call overhead is so much higher on a much faster and better phone. |
hey! @dumganhar I downloaded v3.12 and had absolutely no effect on the performance. The v3.12 and v3.9 have the same results on different devices. |
@Bilalmirza, we only fixed the rendering problem. If your game has audio lags and please refer to #15875 |
My game has no audio yet |
@dumganhar I removed all sounds and calls for sounds from my code a while back. |
@Bilalmirza , could you send me a demo you're using for reproducing the issue? |
@Bilalmirza it only fixed on some Android devices. Could you please create a new issue and describe it in detail? Thanks. |
@minggo I'm really sorry for posting it here. |
@Bilalmirza |
Hi guys, @dumganhar fixed audio engine issue in this #15875. Would you please take a try and give some feedback? Thanks. |
Hey guys! Any chance to have v2 version of this fix? |
@maklaus no, v2 doesn't use new audio engine. |
@minggo so this fps drop (i have it on galaxy tab4 only) is because of audio? But I tried to turn audio conpletely (not to call play methods) and still experience 30-35 fps |
I tried to comment //mapBuffers(); but in CCTextureAtlas.cpp (in v2 there is no Render.cpp) but its not fixed the fps (only fps stats dissapiars) |
@maklaus audio engine is just one issue. And the rendering performance fixed can not be applied to v2, their rendering codes are different. |
@minggo ok, thanks for quick response! |
@maklaus may be you can try as this comment |
Ive seen this fix but I have no experience to adjust it for v2. |
@minggo could you please adapt this solution for Cocos2d-x v2.2.6? I cant understand all these low-level functions at all =( |
is this issue fixed in the latest version of cocos2dx or do i have to go in the code and make the changes ? @minggo |
@minggo, galaxy tab4 still has this problem.I have commont "mapbuffer" |
@moonwith this PR just fix the type of performance issue. So there may be other performance issue in galaxy tab4. |
cocos version: 3.11 |
I had solved this issues ! CCClippingNode.cpp line 59, " new StencilStateManager()" I just write another drawSolidRect( srcPoint,dstPoint) funcions ; FINISHED! |
Hello, guys, did you fix this problem? Here is the screen: https://gyazo.com/835a8b55b2a48c04934bb0ea3554e69f It is after drawing ~20 sprites without any logic, moving objects or animations. |
Some developers report there is performance issue on Android, specially on Android 6.0 + QHD devices. There are also many tickets in forum reporting about it: http://discuss.cocos2d-x.org/t/cocos2d-x-and-poor-updates/29296.
The text was updated successfully, but these errors were encountered: