Android low fps / performance

Android low fps / performance
0

#1

Hi,
In Android (i repeat, only in Android) my game doesn’t work with 60fps. The fps go down as I go through the game. Because of this, it gets stuck when playing.

After many testing i discovered that the cause of it is the sound. My game has a background sound, and simple sounds (effects). When I turn off ALL sounds I can play with 60 fps and everything works fine.

I tested in Android 6 and Android 7.
I’m using cocos 2d-x 3.17 and NDK 16.

I read a lot of posts here about this problem and I tested a lot of alternatives, but nothing works. Even I read in various cocos Changelogs versions that this problem was solved, but i’m using the last cocos2dx version and I’m continue with the problem.

I tested using mp3, ogg and wav, but i get the same results.
Anyone can help me?
Thanks


#2

Hello
May be your using SimpleAudioEngine to implement sounds, try with AudioEngine it may helps to resolve this issue.


#3

Amazing! Thanks man!! That solved the problem.


#4

Hi,
I’m having a rare behavior since I changed to AudioEngine. Maybe AudioEngine isn’t the problem, or maybe yes.

In Android, sometimes the app crashes / freezes. Is in random times, maybe when i’m playing after 10 min, or 15, or 5… or 20… or maybe I can play for 30 mins and everything works fine. Is rare.

Logcat summary when the app stops:

08-20 16:29:37.473 25935-26170/? I/Icing: Post-init done
08-20 16:29:37.474 25935-26170/? I/Icing: Indexing com.google.android.googlequicksearchbox-suggest_query from com.google.android.googlequicksearchbox
08-20 16:29:37.499 25935-26170/? I/Icing: Indexing done com.google.android.googlequicksearchbox-suggest_query
08-20 16:29:37.502 25935-26170/? I/Icing: Indexing com.google.android.gms-internal.3p:Photograph from com.google.android.gms
08-20 16:29:37.515 25935-26170/? I/Icing: Indexing done com.google.android.gms-internal.3p:Photograph
08-20 16:29:37.518 25935-26170/? I/Icing: Indexing com.google.android.gms-emails_data_id from com.google.android.gms
08-20 16:29:37.542 25935-26170/? I/Icing: Indexing done com.google.android.gms-emails_data_id
08-20 16:29:37.544 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:37.544 25935-26170/? E/Icing: Aborting indexing of corpus top_tracks
08-20 16:29:37.546 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:37.546 25935-26170/? E/Icing: Aborting indexing of corpus top_albums
08-20 16:29:37.548 25935-26170/? I/Icing: Indexing com.google.android.gms-sms from com.google.android.gms
08-20 16:29:37.567 25935-26170/? I/Icing: Indexing done com.google.android.gms-sms
08-20 16:29:37.569 25935-26170/? I/Icing: Indexing com.google.android.gms-postals_data_id from com.google.android.gms
08-20 16:29:37.574 25935-26170/? I/Icing: Indexing done com.google.android.gms-postals_data_id
08-20 16:29:37.576 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:37.576 25935-26170/? E/Icing: Aborting indexing of corpus playlists
08-20 16:29:37.578 25935-26170/? I/Icing: Indexing com.google.android.gms-phones_data_id from com.google.android.gms
08-20 16:29:37.584 25935-26170/? I/Icing: Indexing done com.google.android.gms-phones_data_id
08-20 16:29:37.586 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:37.586 25935-26170/? E/Icing: Aborting indexing of corpus artists
08-20 16:29:37.588 25935-26170/? I/Icing: Indexing com.google.android.apps.books-volumes__id from com.google.android.apps.books
08-20 16:29:37.589 2272-5932/? W/ActivityManager: Permission Denial: opening provider com.google.android.apps.books.provider.BooksProvider from ProcessRecord{e25aa 25935:com.google.android.gms/u10a17} (pid=25935, uid=1010017) that is not exported from uid 1010053
08-20 16:29:37.594 25935-26170/? E/Icing: Cursor call threw an exception: Permission Denial: opening provider com.google.android.apps.books.provider.BooksProvider from ProcessRecord{e25aa 25935:com.google.android.gms/u10a17} (pid=25935, uid=1010017) that is not exported from uid 1010053
08-20 16:29:37.639 25935-26170/? I/Icing: Indexing done com.google.android.apps.books-volumes__id
08-20 16:29:37.639 25935-26170/? E/Icing: Aborting indexing of corpus volumes__id
08-20 16:29:37.642 25935-26170/? I/Icing: Not indexing corpus from package com.android.chrome as it has never connected
08-20 16:29:37.642 25935-26170/? E/Icing: Aborting indexing of corpus omnibox
08-20 16:29:37.646 25935-26170/? I/Icing: Indexing com.google.android.videos-shows from com.google.android.videos
08-20 16:29:37.658 2272-5821/? I/ActivityManager: Start proc 27087:com.google.android.videos/u10a98 for content provider com.google.android.videos/.search.IcingContentProvider
08-20 16:29:37.691 2272-3289/? D/MotoSensors: ALS 73
08-20 16:29:37.893 27101-27101/? E/NEW_BHD: Battery Power Supply logging Daemon start!!!!!
08-20 16:29:37.894 27101-27101/? E/NEW_BHD: Cannot run on production devices!
08-20 16:29:38.090 25935-26170/? I/Icing: Indexing done com.google.android.videos-shows
08-20 16:29:38.092 27087-27087/? W/PlayMovies: SyncCallback.getResponse:78 SyncCallback from main thread might cause ANR
08-20 16:29:38.095 25935-26170/? I/Icing: Indexing com.google.android.videos-movies from com.google.android.videos
08-20 16:29:38.131 27087-27087/? W/PlayMovies: SyncCallback.getResponse:78 SyncCallback from main thread might cause ANR
08-20 16:29:38.136 2272-4208/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.160 25935-26170/? I/Icing: Indexing done com.google.android.videos-movies
08-20 16:29:38.165 25935-26170/? I/Icing: Indexing com.google.android.gms-apps from com.google.android.gms
08-20 16:29:38.170 27087-27123/? D/PlayMovies: PersistentCache.cleanup:94 Cache is below limit, no need to shrink: [size=0, limit=5242880]
08-20 16:29:38.206 25319-25507/? I/Finsky: [1815] com.google.android.finsky.ei.b.a(49): Will not allow first-party apps signed by test keys
08-20 16:29:38.208 25319-25507/? I/Finsky: [1815] com.google.android.finsky.contentfilterui.m.a(6): Received content filters request from com.google.android.videos
08-20 16:29:38.241 27087-27128/? W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
08-20 16:29:38.259 27087-27128/? W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
08-20 16:29:38.265 27087-27128/? W/VideoCapabilities: Unrecognized profile/level 0/0 for video/mpeg2
    Unrecognized profile/level 0/2 for video/mpeg2
    Unrecognized profile/level 0/3 for video/mpeg2
08-20 16:29:38.294 2272-3892/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.295 27087-27128/? I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
08-20 16:29:38.313 27087-27087/? D/PlayMovies: TransferService.onCreate:60 creating transfer service
08-20 16:29:38.363 281-4070/? D/WVCdm: Instantiating CDM.
08-20 16:29:38.366 281-2875/? I/WVCdm: CdmEngine::QueryStatus
    Level3 Library Jun 15 2015 14:09:24
08-20 16:29:38.379 25935-26170/? I/Icing: Indexing com.google.android.gms-contacts_contact_id from com.google.android.gms
08-20 16:29:38.385 25935-26170/? I/Icing: Indexing done com.google.android.gms-contacts_contact_id
08-20 16:29:38.387 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:38.387 25935-26170/? E/Icing: Aborting indexing of corpus albums
08-20 16:29:38.389 25935-26170/? I/Icing: Indexing com.google.android.gms-internal.3p:Event from com.google.android.gms
08-20 16:29:38.394 25935-26170/? I/Icing: Indexing done com.google.android.gms-internal.3p:Event
08-20 16:29:38.395 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:38.395 25935-26170/? E/Icing: Aborting indexing of corpus top_artists
08-20 16:29:38.398 25935-26170/? I/Icing: Indexing com.google.android.gms-internal.3p:DigitalDocument from com.google.android.gms
08-20 16:29:38.402 25935-26170/? I/Icing: Indexing done com.google.android.gms-internal.3p:DigitalDocument
08-20 16:29:38.404 25935-26170/? I/Icing: Indexing com.google.android.gm-messages/com.google/alansaura87%40gmail.com from com.google.android.gm
08-20 16:29:38.416 2272-4666/? I/ActivityManager: Start proc 27130:com.google.android.gm/u10a70 for content provider com.google.android.gm/.provider.SearchQuery$Provider
08-20 16:29:38.425 281-2875/? W/WVCdm: Could not load liboemcrypto.so. Falling back to L3.  dlopen failed: library "liboemcrypto.so" not found
08-20 16:29:38.543 27130-27130/? W/System: ClassLoader referenced unknown path: /data/app/com.google.android.gm-2/lib/arm
08-20 16:29:38.742 27130-27130/? W/EasBundling: in EasBundling.init, isBundlingEnabled=true
08-20 16:29:38.765 27130-27146/? D/ActivityThread: Loading provider com.google.android.gmail.provider;com.android.mail.notifier;com.google.android.gm.email.provider;com.google.android.gm.email.notifier: com.android.email.provider.EmailProvider
08-20 16:29:38.765 27130-27145/? I/UnifiedEmail: getAccountsCursor
08-20 16:29:38.767 2272-3508/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.932 27130-27130/? W/GAV2: Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
08-20 16:29:38.938 2272-2282/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.938 2272-4208/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.939 2272-5931/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.939 2272-4012/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.940 2272-4377/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.941 2272-5821/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.956 27130-27146/? I/UnifiedEmail: Initiated Service map for: [gPop3, gLegacyImap, gEas, gmail]
08-20 16:29:38.958 2272-5931/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.960 2272-4012/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.961 2272-4012/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.961 2272-5821/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:38.985 2272-3377/? W/ActivityManager: Unable to start service Intent { cmp=com.google.android.gm/com.android.email.service.AttachmentService } U=10: not found
08-20 16:29:39.009 2272-5931/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.011 2272-4377/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.012 2272-4012/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.017 27130-27158/? I/Gmail: Observing account changes for notifications
08-20 16:29:39.043 27130-27130/? I/Gmail: Recorded initial entry point: OTHER_NON_UI.
08-20 16:29:39.043 27130-27130/? I/Exchange: EasService.onCreate
08-20 16:29:39.045 2272-3377/? W/ActivityManager: Unable to start service Intent { cmp=com.google.android.gm.exchange/com.android.exchange.service.EasService } U=10: not found
08-20 16:29:39.046 27130-27130/? I/Exchange: EasService.onCreate stoppedOldService=false
08-20 16:29:39.049 27130-27130/? I/Exchange: needResyncCalendar: false, hasCalendarPermission: false, needResyncContacts: false, hasContactsPermission: true
08-20 16:29:39.052 27130-27160/? I/Exchange: RestartPingTask
08-20 16:29:39.055 27130-27161/? I/UnifiedEmail: getAccountsCursor
08-20 16:29:39.056 2272-3892/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.074 27130-27130/? I/Exchange: RestartPingsTask did not start any pings.
08-20 16:29:39.083 27130-27130/? I/Exchange: onDestroy
08-20 16:29:39.155 27130-27153/? I/UnifiedEmail: notifyAccountChanged
08-20 16:29:39.162 27130-27153/? I/Gmail: calculateUnknownSyncRationalesAndPurgeInBackground: queueing
08-20 16:29:39.171 27130-27153/? I/Gmail: calculateUnknownSyncRationalesAndPurgeInBackground: queueing
08-20 16:29:39.174 27130-27153/? I/Gmail: calculateUnknownSyncRationalesAndPurgeInBackground: running
08-20 16:29:39.175 27130-27153/? I/Gmail: calculateUnknownSyncRationalesAndPurgeInBackground: running
08-20 16:29:39.266 2272-5550/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.273 2272-3886/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.276 2272-3377/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.287 2272-5932/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.322 25935-26170/? I/Icing: Indexing done com.google.android.gm-messages/com.google/alansaura87%40gmail.com
08-20 16:29:39.328 25935-26170/? I/Icing: Indexing com.google.android.gms-internal.3p:MusicRecording from com.google.android.gms
08-20 16:29:39.336 25935-26170/? I/Icing: Indexing done com.google.android.gms-internal.3p:MusicRecording
08-20 16:29:39.342 25935-26170/? I/Icing: Not indexing corpus from package com.google.android.music as it has never connected
08-20 16:29:39.342 25935-26170/? E/Icing: Aborting indexing of corpus songs
08-20 16:29:39.351 25935-26170/? I/Icing: Indexing done com.google.android.gms-apps
08-20 16:29:39.354 2272-2282/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.360 27130-27145/? I/UnifiedEmail: getAccountsCursor
08-20 16:29:39.361 2272-3377/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.376 27130-27146/? I/UnifiedEmail: getAccountsCursor
08-20 16:29:39.378 2272-4012/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
08-20 16:29:39.748 2272-3289/? D/MotoSensors: ALS 62
08-20 16:29:40.689 27039-27064/? I/GAV2: Thread[GAThread,5,main]: No campaign data found.
08-20 16:29:40.697 25935-25935/? I/GAv4-SVC: Google Analytics 12.8.74 is starting up.
08-20 16:29:40.992 2272-3289/? D/MotoSensors: ALS 51

Suggestions?

I’m surprised by these lines:

08-20 16:29:37.594 25935-26170/? E/Icing: Cursor call threw an exception: Permission Denial: opening provider com.google.android.apps.books.provider.BooksProvider from ProcessRecord{e25aa 25935:com.google.android.gms/u10a17} (pid=25935, uid=1010017) that is not exported from uid 1010053
08-20 16:29:37.639 25935-26170/? I/Icing: Indexing done com.google.android.apps.books-volumes__id
08-20 16:29:37.639 25935-26170/? E/Icing: Aborting indexing of corpus volumes__id
08-20 16:29:37.642 25935-26170/? I/Icing: Not indexing corpus from package com.android.chrome as it has never connected
08-20 16:29:37.642 25935-26170/? E/Icing: Aborting indexing of corpus omnibox

#5

Hi @tranthor
I think this issue is not related to sound.May be, you can check by commenting all sound related code.


#6

I had similar experience with sounds. My solution may not be your answer, but here’s my story:

When I use SimpleAudioEngine, playing .ogg sound file for sound effect sometimes crashes my app.

and even .wav file sometimes crashes on some devices depending on its codecs. (before that I didn’t know even .wav file has multiple codecs!)

Finally I use SimpleAudioEngine with .wav file encoded with Audacity.(free opensource audio edit tool) and no crash report ever since.

For background music, I use mp3 file only.