cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.25k stars 7.06k forks source link

Performance issue on android devices if set c++_static as APP_STL in application.mk #18286

Open bingsoo opened 7 years ago

bingsoo commented 7 years ago

Steps to Reproduce:

  1. set c++_static as APP_STL in application.mk file
  2. build release. (only happen in release mode)

game will jitter every 4 seconds.

minggo commented 7 years ago

Why you need to change to c++_static?

pyrosphere commented 7 years ago

I don't know about bingsoo but I use c++_static instead of gnustl_static because it doesn't support some functions, like std::to_string.

ilqvya commented 7 years ago

Use this: http://www.boost.org/doc/libs/1_65_1/doc/html/boost_lexical_cast.html

bingsoo commented 7 years ago

@minggo like @pyrosphere, I used c++_static to avoid some build errors on my project. I don't think this issue is major one since I can simply use gnustl_static instead but I created this issue to track or help someone who suffer debugging like me who set c++_static as APP_STL. If c++_static is not supported in android device, I think the cocos2d-x document should at least notice it.

minggo commented 7 years ago

We don't know if it is supported as we don't test it. So i can't say it is good or not as we don't have enough resources to test every situation.

deguilardi commented 7 years ago

I need to use this library to use some basic functions as codecvt.

@minggo google says "LLVM's libc++ is the C++ standard library that has been used by the Android OS since Lollipop, and in the future WILL BE THE ONLY STL available in the NDK." [https://developer.android.com/ndk/guides/cpp-support.html#libc]

Isn't it the time to start testing it? Supporting it? What if Google decides stop supporting it for good (as it predicted)?

minggo commented 7 years ago

google says "LLVM's libc++ is the C++ standard library that has been used by the Android OS since Lollipop, and in the future WILL BE THE ONLY STL available in the NDK."

I can not find the information in https://developer.android.com/ndk/guides/cpp-support.html#libc. And the doc says libc++ is not stable.

deguilardi commented 7 years ago

@minggo The text I wrote is the very first phrase of the link I sent. How could you didn't find it? About not being stable, there must be a language barrier here, the doc says "Prior to NDK r16, the NDK's libc++ is not stable" - PRIOR TO r16 - in other words: in older versions

Not paying attention to this is going to cause the same thing that happened when google removed the "android" command and the projects stopped compiling. Do you remember?

The good news are that I could make everything works great on the c++_static lib. There are only a million warnings but nothing bad.

deguilardi commented 7 years ago

check this link: https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md#ndk-r18 it clearly says the libc++ will be the only STL available after the first quarter of 2018. We've got 5 months.

minggo commented 7 years ago

Thanks for the link. The page is automatically translated to Chinese when i open the link, it is cookie related, i will fix it the check the English version.

cocos2d-x doesn't use libc++ is because we changed it in v3.11 or other version, i don't remembered, and meet some strange crash issues. That's why i don't want to change to use libc++ until it is stable.

deguilardi commented 7 years ago

a

deguilardi commented 7 years ago

Well, in April 2018 the libc++ will be the only option... Let me know if you need me to help on this.

minggo commented 7 years ago

Thanks, i think you can help to report issues or sent PR to fix issues that are libc++ related.

deguilardi commented 7 years ago

Just got my first major error related to the libc++_static. I updated the gradle to the version 4.1 and from now on I am getting the following error: Error:(506, 63) error: incomplete type 'std::__ndk1::is_move_assignable' used in nested name specifier

The error is triggered when the compiler is compiling the file "cocos/./base/CCConsole.cpp:318:28". If I totally remove dependencies on the codecvt and compile the project using the gnustl_static, everything works great.

Other apps I have that don't necessarily need to use the libc++_static (they use gnustl_static) work great on gradle 4.1.

Volodymyr-13 commented 7 years ago

Check this also https://github.com/cocos2d/cocos2d-x/pull/18470

deguilardi commented 7 years ago

@KAMIKAZEUA That is great! anyways, this won't resolve this specific issue.