On some Android devices vsprintf
returns -1 with any buffer size inside separated thread for non-english languages.
- Take any format function (i've tried many). For example this one https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.17/cocos/base/ccUTF8.cpp#L43
- Call format function in separated thread twice with delay (1-2 sec) with non-english language text.
std::thread _thread = std::thread([](){
std::string test1 = format("Any text here. Language doesn't matter %d", 1);
// sleep is important. vsnprint stop working (returns -1) after some delay, not immediately
sleep(2);
// non-english language is important
std::string test2 = format("运送%d个乘客!电工、防火员和警察不算", 1);
});
_thread.detach();
Or use this test case
- NDK Version: staring from r15c (with r14b everything is fine)
- Build system: cmake/ndk-build
- Host OS: MacOS 10.13.6/Linux Ubuntu 16.04
- Compiler: clang
- ABI: armeabi-v7a
- STL: c++_static
- NDK API level: 16
- Device API level: 24, 26
- Samsung GT-I9082 (Android 4.2.2, API 17)
- Xiaomi Mi A1 (Android 8.1.0, API 27)
- DIGMA VOX S501 3G VS5002PG (Android 5.1, API 22)
- TCL 5065D (Android 5.1.1, API 22)
- Sony E5303 (Android 6.0 API 23)
- Google Pixel XL (Android 9, API 28)
- Google Pixel 3 XL (Android 9, API 28)
- Xiaomi Mi PAD 3 (Android 7.0.0, API 24)
- TCT (Alcatel) Alcatel 1X (U5A_PLUS_4G), Android 8.1
- Xiaomi Redmi 6A (cactus), Android 8.1
- Xiaomi Redmi 6 (cereus), Android 8.1
- Huawei Honor 7A (HWDUA-M), Android 8.1