You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since version 3.6.x, CocosCreator has been using Google’s AGDK/GameActivity, which claims to significantly reduce the likelihood of application ANRs. Our company has developed numerous products based on the 3.7.x engine version, but even after releasing them on Google Play, the ANR rate remains high.
I found that many ANRs are originating from GameActivity.onPauseNative (clearly related to switching between the foreground and background of the game). Further analysis revealed that the issue is related to the pthread_cond_timedwait function, which is used in android_native_app_glue.c.
I have also noticed that many game developers are encountering the same issue.
Relevant error log output
None
Steps to reproduce
To address this ANR, I spent some time understanding the internal workings and driving mechanisms of AGDK and eventually found a method to fix this ANR.
Cocos Creator version
3.6.x+
System information
Android
Issue description
Since version 3.6.x, CocosCreator has been using Google’s AGDK/GameActivity, which claims to significantly reduce the likelihood of application ANRs. Our company has developed numerous products based on the 3.7.x engine version, but even after releasing them on Google Play, the ANR rate remains high.
I found that many ANRs are originating from
GameActivity.onPauseNative
(clearly related to switching between the foreground and background of the game). Further analysis revealed that the issue is related to thepthread_cond_timedwait
function, which is used in android_native_app_glue.c.I have also noticed that many game developers are encountering the same issue.
Relevant error log output
None
Steps to reproduce
To address this ANR, I spent some time understanding the internal workings and driving mechanisms of AGDK and eventually found a method to fix this ANR.
Here is my modified code.
android_native_app_glue.h
android_native_app_glue.c
This solution has been validated on our products, and the ANR rate for most of our products has reduced to one-third of the original rate.
I also reported this bug to Google, and they have responded. Here is the IssueTracker link, feel free to check it out if you are interested.
https://issuetracker.google.com/issues/377940980
I hope Cocos can merge this code into the 3.8.5 release version. Thank you very much.
(之前给引擎提过PR,有点太麻烦了,所以用提Issues方式提交这次修改,修改非常简单,只涉及两个c文件,其他开发者有兴趣也可以在自己的版本中合并修改)
Minimal reproduction project
None
The text was updated successfully, but these errors were encountered: