androidcocos2d-xandroid-5.0-lollipopcocos2d-x-3.0cocos2d-x-2.x

Cocos2dx soundengine issue on Android Lollipop


I am having an issue with Cocos2dx 2.2.6 on Android 5. After playing my game for a little while it starts to severely lag. This does not happen with Android 4. After doing some research many people have said it is a problem with Android 5 working with Cocos2dx's Audio engine. Unfortunately I have not come up with a solution for this. I am sure this is the problem because if I take sounds and music out of my game on Android 5 then there is no lag at all. Some people have said to take the sound engine files from Cocos2dx 3 but I am not sure how to set that up. I believe this is a serious problem then many cocos2dx 2.2.6 users are having so I feel someone has come up with some sort of solution. Also below are some errors I am receiving if that helps.

05-19 19:24:54.472: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:54.472: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:55.724: E/AudioTrack(16766): AudioTrack::set : Exit
05-19 19:24:56.304: E/ExtMediaPlayer-JNI(16766): QCMediaPlayer could not be located....
05-19 19:24:56.304: E/MediaPlayer-JNI(16766): QCMediaPlayer mediaplayer NOT present
05-19 19:24:56.374: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:56.374: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:56.604: E/ExtMediaPlayer-JNI(16766): QCMediaPlayer could not be located....
05-19 19:24:56.604: E/MediaPlayer-JNI(16766): QCMediaPlayer mediaplayer NOT present
05-19 19:24:56.644: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:56.644: E/MediaPlayer(16766): Should have subtitle controller already set
05-19 19:24:57.645: E/AudioTrack(16766): AudioTrack::set : Exit
05-19 19:24:57.846: E/AudioTrack(16766): AudioTrack::set : Exit
05-19 19:24:58.076: E/AudioTrack(16766): AudioTrack::set : Exit
05-19 19:24:58.276: E/AudioTrack(16766): AudioTrack::set : Exit

Solution

  • Like you said, this is a known problem of the old SimpleAudioEngine with android 5.x.

    A new implementation was integrated into cocos2d-x 3.3 and onwards, and a patch was written for 2.x. You can get it and some more info here: http://blog.cocos2d-x.org/2015/04/performance-issue-caused-by-simpleaudioengine-on-android-5-0/