I can’t reproduce on my end too. It’s happened on wide range of devices, android versions.
The only notable info is 76% of this ANR is when app in background.
@Tomas1856 The majority of our ANR start with com.unity3d.player.UnityPlayer.surfaceDestroyed too. My guess is UnityPlayer blocks ‘main’ thread waiting on some semaphore for something queued on to ‘UnityMain’ or other thread. I have no access to sources to check this hypothesis and I have no clues how to resolve that ANR.
Can you help with investigation, please?
main (timed waiting): tid=1 systid=16340
at sun.misc.Unsafe.park(Native method)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1063)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1358)
at java.util.concurrent.Semaphore.tryAcquire(Semaphore.java:415)
at com.unity3d.player.UnityPlayer.updateDisplayInternal(unavailable)
at com.unity3d.player.UnityPlayer.updateGLDisplay(unavailable)
at com.unity3d.player.UnityPlayer.access$1100(unavailable)
at com.unity3d.player.UnityPlayer$19.surfaceDestroyed(unavailable)
at android.view.SurfaceView.notifySurfaceDestroyed(SurfaceView.java:1943)
at android.view.SurfaceView.updateSurface(SurfaceView.java:1239)
at android.view.SurfaceView.setWindowStopped(SurfaceView.java:291)
at android.view.SurfaceView.surfaceDestroyed(SurfaceView.java:1767)
at android.view.ViewRootImpl.notifySurfaceDestroyed(ViewRootImpl.java:1891)
at android.view.ViewRootImpl.setWindowStopped(ViewRootImpl.java:1826)
at android.view.WindowManagerGlobal.setStoppedState(WindowManagerGlobal.java:700)
at android.app.Activity.performStop(Activity.java:8398)
at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4981)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4960)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:5034)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:233)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2135)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8059)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Yes it crashes because Activity.onPause in main (as I can see from crash logs) is synchronized with UnityMain thread via a semaphore lock. Thus the main can be blocked by heavy operation in UnityMain thread. In our case it is a loading.
We do loading at Unity Main. Currently it is a heavy synchronous routine but it is a script running at Unity Main and technically it must not cause an ANR.
Player minimizes his app and it goes to background. UnityPlayerActivity.onPause is triggered by Android on the main thread.
Currently I believe that UnityPlayerActivity.onPause waits for UnityMain which is busy loading our files. main is blocked - ANR is fired. That’s it.