Android 5.0 Lollipop freezes with Cocos2dx 3.2 (Version L API 21)

Loaded up the latest preview of Android 5.0 and tested ALL of my games on it from the Play Store. Result: All of them freeze up. Ouch. Clearly issues with the new version of Android but thought I’d let you know the results are not good. My findings so far:

  • You must have the library name specified in the manifest file under application tag:
    <meta-data android:name="android.app.lib_name"
            android:value="hello" />

Fixing that issue got the native C++ library up and running. Always worked without it before.


  • Fixing that got me into Label::createWithBMFont hell. It turns out there is a major problem with sscanf call and it totally freezes up when parsing a plain text fnt file. The easiest fix is to use the binary format version of the fnt file which doesn’t require sscanf. Here is the line that it freezes on inside BMFontConfiguration class:

sscanf(value.c_str(), “padding=%d,%d,%d,%d”, &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);

It’ll freeze on any of the sscanf calls so that’s why I suggest not using that format and go binary. Now on to the next problem…


  • SimpleAudioEngine::getInstance()->playBackgroundMusic will freeze. Commented that out for now and was able to get my game running.

D/tms::playMusic( 7039): Playing music music.mp3
E/MediaPlayer( 7039): Should have subtitle controller already set
E/MediaPlayer( 7039): Should have subtitle controller already set
D/NuPlayerDriver( 190): stop(0xb2693280)
D/audio_hw_primary( 190): disable_audio_route: reset and update mixer path: low-latency-playback
D/audio_hw_primary( 190): disable_snd_device: snd_device(2: speaker)
I/wpa_supplicant( 8026): wlan0: CTRL-EVENT-SCAN-STARTED

I spent all day trying to get my app up and running so hope this information helps.

Cheers,
Todd

1 Like

Confirmed the sscanf / loading of text based fnt file can be fixed by using NDK 10c. I was compiling with 10b. The media player still freezes on playback of music though. For now I’ve fixed that by checking android version for 5.0 and not playing music. Hopefully I can find a better workaround than that.

@tmsoft, I have no problems with audio when using .ogg files (though I’m still using an older Andriod L preview image).

Confirm – on both Nexus 5 and Nexus 7 with any version of the NDK (8e, 9b, 9c, 9d, 10b, 10c) and any version of Cocos2d-x (2.1, 2.2., 2.3, 3.1, 3.2) that MediaPlayer causes an immediate freeze.

I logged an issue – please star, share and upvote:

https://code.google.com/p/android-developer-preview/issues/detail?id=1787

Fixed at https://github.com/cocos2d/cocos2d-x/pull/9088

2 Likes

How are you determining where the app is freezing? I am getting freezes even though I applied the latest MediaPlayer-related patches and sticking to strictly binary-based fnt files.

I determined the freeze location by adding a bunch of log messages… If you use NDK r10c the problem with scanf goes away.

Thanks, I tried that but I can’t get past errors like this, ugh

/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ios:668: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:479: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ios:734: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ios:524: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:490: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:294: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:294: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:294: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:294: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/iosfwd:123: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ios:524: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ios:524: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:973: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/platform/android/jni/TouchesJni.cpp:90: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/ui/UILayout.cpp:51: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/ui/UIScrollView.cpp:38: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./2d/CCDrawingPrimitives.cpp:69: error: relocation overflow in R_ARM_THM_CALL
/Users/Justin/Desktop/tools/android-ndk-r10c/sources/cxx-stl/llvm-libc++/libcxx/include/map:1055: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:578: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:579: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:580: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:581: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:582: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:583: error: relocation overflow in R_ARM_THM_CALL
jni/../../cocos2d/cocos/./deprecated/CCDeprecated.cpp:584: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/iostream.cpp:34: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4685: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4675: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/src/locale.cpp:4627: error: relocation overflow in R_ARM_THM_CALL

Any tips?

Hi @Jgod , I’m having the same problem as yours, have you solved it?
I’m using ndk-r10c, and I changed libcurl to the newest version, which is recompiled, and I added “LOCAL_ARM_MODE := arm” to all Android.mk files. But I’m with no luck.

I haven’t solved it either, tried the same as you. :’(
For now, I’m stuck on r9d and missing out on 5.0 compatibility (very small % of users fortunately, who knows for how long…) because of the freezes.

@Jgod I got no build errors when I changed my Application.mk with solution B in this thread. Hope it helps you.

@Jgod

I use cocos2dx 3.2 final release + ndk r10c. When I tried to build release version of my game. I met the same issue as yours. (works fine when build debug version)

libc++/libcxx/include/ostream:973: error: relocation overflow in R_ARM_THM_CALL
jni/…/…/cocos2d/cocos/platform/android/jni/TouchesJni.cpp:90: error: relocation overflow in R_ARM_THM_CALL

Have you resolve this issue? Any tips?

Thanks a lot

I just tried this solution now (the 2nd one in that post), and it works for me!

Thanks for the tip @wujian!