ANR onResume and surfaceDestroyed

Hello,

After the update from 5.3 to 5.5 we got a lot of ANR’s during our closed playtest (around 1k people). onResume with 102 affected users takes the first place among crashes and ANR’s in Google Play Console, and surfaceDestroyed takes the third place.

We have found a related topic on forums (https://forums.unrealengine.com/t/getting-libunreal-so-android-app-set-activity-state-anr-on-ue5-5-android/2342665), but there wasn’t much response.

Maybe there are any insights regarding this issue and something that we could do on our side to sort it out?

Steps to Reproduce
Don’t have exact steps

Hi Ihar,

The Android window lifecycle implementation was overhauled quite significantly in 5.6 to addresses issues of this sort. The relevant CLs are 41412619 and 41488823. Should backporting prove problematic or the ANR issues persist, we would ask that you share stack call stacks at the time of the hang for further diagnosis.

Best regards.

Hello!

There are stack traces of most frequent ANR events. Could you please look through them and share some insights?

                  "ZygoteInit.java:1019 com.android.internal.os.ZygoteInit main",
                    "RuntimeInit.java:569 com.android.internal.os.RuntimeInit$MethodAndArgsCaller run",
                    "None:None java.lang.reflect.Method invoke",
                    "ActivityThread.java:7941 android.app.ActivityThread main",
                    "Looper.java:288 android.os.Looper loop",
                    "Looper.java:201 android.os.Looper loopOnce",
                    "Handler.java:99 android.os.Handler dispatchMessage",
                    "Handler.java:942 android.os.Handler handleCallback",
                    "Choreographer.java:1302 android.view.Choreographer$FrameDisplayEventReceiver run",
                    "Choreographer.java:874 android.view.Choreographer doFrame",
                    "Choreographer.java:960 android.view.Choreographer doCallbacks",
                    "Choreographer.java:1327 android.view.Choreographer$CallbackRecord run",
                    "Choreographer.java:1319 android.view.Choreographer$CallbackRecord run",
                    "ViewRootImpl.java:9256 android.view.ViewRootImpl$TraversalRunnable run",
                    "ViewRootImpl.java:2372 android.view.ViewRootImpl doTraversal",
                    "ViewRootImpl.java:2882 android.view.ViewRootImpl performTraversals",
                    "ViewGroup.java:1621 android.view.ViewGroup dispatchWindowVisibilityChanged",
                    "ViewGroup.java:1621 android.view.ViewGroup dispatchWindowVisibilityChanged",
                    "ViewGroup.java:1621 android.view.ViewGroup dispatchWindowVisibilityChanged",
                    "View.java:15454 android.view.View dispatchWindowVisibilityChanged",
                    "SurfaceView.java:348 android.view.SurfaceView onWindowVisibilityChanged",
                    "SurfaceView.java:1053 android.view.SurfaceView updateSurface",
                    "SurfaceView.java:1878 android.view.SurfaceView notifySurfaceDestroyed",
                    "NativeActivity.java:283 android.app.NativeActivity surfaceDestroyed",
                    "None:None android.app.NativeActivity onSurfaceDestroyedNative",
                    "None:40 None android::onSurfaceDestroyed_native",
                    "None:None None None",
                    "None:72 None pthread_cond_wait",
                    "None:144 None __futex_wait_ex",
                    "None:28 None syscall"
                    "ZygoteInit.java:929 com.android.internal.os.ZygoteInit main",
                    "RuntimeInit.java:619 com.android.internal.os.RuntimeInit$MethodAndArgsCaller run",
                    "None:None java.lang.reflect.Method invoke",
                    "ActivityThread.java:9634 android.app.ActivityThread main",
                    "Looper.java:342 android.os.Looper loop",
                    "Looper.java:257 android.os.Looper loopOnce",
                    "Handler.java:107 android.os.Handler dispatchMessage",
                    "ActivityThread.java:2728 android.app.ActivityThread$H handleMessage",
                    "unavailable:0 android.app.ActivityThread -$$Nest$mhandleServiceArgs",
                    "ActivityThread.java:5752 android.app.ActivityThread handleServiceArgs",
                    "ANRService.java:14 net.wargaming.blitz.ANRService onStartCommand",
                    "Thread.java:356 java.lang.Thread sleep",
                    "Thread.java:451 java.lang.Thread sleep",
                    "None:None java.lang.Thread sleep"
                    "ZygoteInit.java:997 com.android.internal.os.ZygoteInit main",
                    "RuntimeInit.java:627 com.android.internal.os.RuntimeInit$MethodAndArgsCaller run",
                    "None:None java.lang.reflect.Method invoke",
                    "ActivityThread.java:8107 android.app.ActivityThread main",
                    "Looper.java:222 android.os.Looper loop",
                    "MessageQueue.java:335 android.os.MessageQueue next",
                    "None:None android.os.MessageQueue nativePollOnce",
                    "None:44 None android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)",
                    "None:112 None android::Looper::pollOnce(int, int*, int*, void**)",
                    "None:916 None android::Looper::pollInner(int)",
                    "None:112 None (anonymous namespace)::Receiver::handleEvent(int, int, void*)",
                    "None:124 None _JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...)",
                    "None:500 None art::JNI<false>::CallObjectMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)",
                    "None:148 None art::ConditionVariable::WaitHoldingLocks(art::Thread*)",
                    "None:28 None syscall"
                    "ZygoteInit.java:1068 com.android.internal.os.ZygoteInit main",
                    "RuntimeInit.java:582 com.android.internal.os.RuntimeInit$MethodAndArgsCaller run",
                    "None:None java.lang.reflect.Method invoke",
                    "ActivityThread.java:8444 android.app.ActivityThread main",
                    "Looper.java:334 android.os.Looper loop",
                    "Looper.java:233 android.os.Looper loopOnce",
                    "Handler.java:106 android.os.Handler dispatchMessage",
                    "ActivityThread.java:2459 android.app.ActivityThread$H handleMessage",
                    "TransactionExecutor.java:97 android.app.servertransaction.TransactionExecutor execute",
                    "TransactionExecutor.java:176 android.app.servertransaction.TransactionExecutor executeLifecycleState",
                    "ActivityTransactionItem.java:45 android.app.servertransaction.ActivityTransactionItem execute",
                    "ResumeActivityItem.java:54 android.app.servertransaction.ResumeActivityItem execute",
                    "ActivityThread.java:5145 android.app.ActivityThread handleResumeActivity",
                    "ActivityThread.java:5102 android.app.ActivityThread performResumeActivity",
                    "Activity.java:8647 android.app.Activity performResume",
                    "Instrumentation.java:1526 android.app.Instrumentation callActivityOnResume",
                    "GameActivity.java:1 com.epicgames.unreal.GameActivity onResume",
                    "NativeActivity.java:211 android.app.NativeActivity onResume",
                    "None:None android.app.NativeActivity onResumeNative",
                    "None:None None None",
                    "None:72 None pthread_cond_wait",
                    "None:144 None __futex_wait_ex(void volatile*, bool, int, bool, timespec const*)",
                    "None:28 None syscall"

Thanks a_perehodchenko.

The Java stacks do appear to point to a deadlock, likely due to a lock in another native thread. Do you have access to the native thread stack dumps when these occur?

Best regards.