Android ANR Issue

Hello, friends.

Today, I’ve brought up a chronic issue we’re facing. We’ve been trying to resolve it on our own, but it seems quite challenging.

First, let me outline our development environment:

Cocos Creator Version: 3.8.1
Target SDK: 33

We’re currently using these for our game.

We’ve been experiencing frequent ANRs (Application Not Responding) while our game is live. This issue seems to have started after upgrading to this engine version from the previous 3.7.x, which didn’t have this problem.

The ANR logs are as follows, but I’m not sure where to start in terms of troubleshooting.

Is there anyone who can help us out with this?

#00 pc 0x0000000000089af4 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+36)
#01 pc 0x000000000008e4d8 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex+148)
#02 pc 0x00000000000f4964 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_cond_timedwait+140)
#03 pc 0x00000000002ae670 /data/app/~~hjYYL-mYHtFeiwyui7-eTA==/com.chamelio.magicraft-KQsKaOo5pPC5yt0v7HB1Hg==/split_config.arm64_v8a.apk (android_app_set_activity_state+307200) (BuildId: b265e677a1024ac1fb31fefcb35a23d932ce41da)
at com.google.androidgamesdk.GameActivity.onPauseNative (GameActivity.java)
at com.google.androidgamesdk.GameActivity.onPause (GameActivity.java:299)

We will take a look the modification of related codes.

Is your Target SDK also 33 in your 3.7.x version?

Yes it was. But this error was happened after I upgrade engine to 3.8.1

Could you upload anr file from /data/anr/xx.txt ?
With this file information, we can obtain the execution stack of the game thread.

here is the stack trace file

Unfortunately, it is not currently reproduced.

stacktrace.log.zip (7.7 KB)

Has this file been trimmed? Normally there should be v8 thread information, but I didn’t see any game thread related information in the uploaded file.

The logs I shared are from the Google Play Developer Console. Currently, it’s challenging to reproduce the issue, so it’s difficult to identify the exact error point on our own. If there’s another way to obtain the logs, please let me know. I’ll then attach the file again. @freely0417

Are there any large audio files used in your project?

We got the same ANR on 3.8.x, it’s very small impact on our game but we have it too.
We don’t use large audio file and as gandangf we cannot reproduce it, we just see this on google play.

@Azaratur Are there reward-based ads in your game too? Based on my current guess, it seems that issues mainly occur when the reward-based ad logic is executed.

I too have the same issue. An error seems to occur in rewarded advertising. This is very fatal.

Sorry I always forget to check this forum…
We have implemented Google Admob Rewarded videos, but as far as I see we got that ANR any time the app goes in pause.

Which advertising SDK is integrated, and does the launch of an activity have an independent process?

Could you upload your demo?

Our game is live on Google play.

In your game, what is the approximate size of the audio files, how many can be played simultaneously, and what is the maximum number?

Are there logs from other threads when an ANR occurs?

After reward ad logic executed. What tasks have you executed and how did you notify the game?

In your game, what is the approximate size of the audio files, how many can be played simultaneously, and what is the maximum number?
Are there logs from other threads when an ANR occurs?

Audio are not the problem. We did test it even without audio.
Also the ANR is clrearly on “onPauseNative”, so it’s should be related to some sort of lag between comunication from java to c++/js

After reward ad logic executed. What tasks have you executed and how did you notify the game?

There is no any task on Java code, just a call to ‘CocosJavascriptJavaBridge.evalString’ and nothing else on Typescript.
That’s not a reward but an Interstitial.

"What version of the AdMob SDK have you integrated?