3.6.1 Android生命周期方法导致ANR

cocos3.6.1 Android端游戏页面调用onStopNative, onResumeNative, onPauseNative, onSurfaceDestroyedNative等生命周期方法时会导致ANR, 麻烦大佬们看下

  • 完整报错堆栈如下

    ANR_EXCEPTION
    ANR Input dispatching timed out (f681533 com.activities.NavBarActivity (server) is not responding. Waited 10003ms for MotionEvent)

    com.google.androidgamesdk.GameActivity.onStopNative(GameActivity.java)
    com.google.androidgamesdk.GameActivity.void onStop()(GameActivity.java:331)
    com.cocos.lib.CocosActivity.void onStop()(CocosActivity.java:174)
    android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1496)
    android.app.Activity.performStop(Activity.java:8536)
    android.app.ActivityThread.callActivityOnStop(ActivityThread.java:5787)
    android.app.ActivityThread.performStopActivityInner(ActivityThread.java:5731)
    android.app.ActivityThread.handleStopActivity(ActivityThread.java:5832)
    android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:234)
    android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    android.os.tekiapm.ProxyHandlerCallback.handleMessage(SourceFile:4)
    android.os.Handler.dispatchMessage(Handler.java:102)
    android.os.Looper.loopOnce(Looper.java:226)
    android.os.Looper.loop(Looper.java:313)
    android.app.ActivityThread.main(ActivityThread.java:8751)
    java.lang.reflect.Method.invoke(Native method)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

  • 其他生命周期方法ANR

    com.google.androidgamesdk.GameActivity.onResumeNative(GameActivity.java)
    com.google.androidgamesdk.GameActivity.void onResume()(GameActivity.java:310)
    com.cocos.lib.CocosActivity.void onResume()(CocosActivity.java:161)

    com.google.androidgamesdk.GameActivity.onPauseNative(GameActivity.java)
    com.google.androidgamesdk.GameActivity.void onPause()(GameActivity.java:304)
    com.cocos.lib.CocosActivity.void onPause()(CocosActivity.java:152)

    com.google.androidgamesdk.GameActivity.onSurfaceDestroyedNative(GameActivity.java)
    com.google.androidgamesdk.GameActivity.void surfaceDestroyed(android.view.SurfaceHolder)(GameActivity.java:382)
    android.view.SurfaceView.updateSurface(SurfaceView.java:629)
    android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:257)
    android.view.View.dispatchWindowVisibilityChanged(View.java:12258)

我们也遇到了 后续有解决不?

遇到了 555

顶一下帖子。

挖, 3.7.2, 遇到了
com.google.androidgamesdk.GameActivity.onSurfaceDestroyedNative

com.google.androidgamesdk.GameActivity.onPauseNative
是重灾区

在 ./native/cocos/platform/android/java/libs/game-sdk.jar 中

@Zeinx_ 有解决办法吗?

更新一下最新情况:
通过几次发版排查, 移除 Build Config 中的 VULKAN rennder BackEnd, 线上出现此类型 ANR 的情况减少了.
对于后续遇到这个问题的朋友们, 可以尝试这个方法, 没有必要的情况下, 不要勾选 VULKAN

真的难测… 要是帮到谁的线上产品, 可以考虑请我喝饮料

更新一下:
之前的办法缓解但是没有根除

升级到了 3.8.0 仍然有这个 ANR 问题, 最近堆栈是
com.google.androidgamesdk.GameActivity.onPauseNative (GameActivity.java)

firebase 提示
This thread blocked the thread tagged as “Triggered ANR”. If this thread is tagged as both “Root Blocking” and “Triggered ANR”, then there are no other threads that block this thread.

顶一下。我们也遇到了。恶心。

顶一下 在3.8.2 也遇到了 希望解决一下

有没有人站出来 给个说法

请参考 这个 PR的修改,有结果烦请反馈,谢谢

还是有此类问题。