microsoft / appcenter-sdk-android

Development repository for the App Center SDK for Android
Other
279 stars 134 forks source link

Several ANRs when report #1691

Closed jmmortega closed 6 months ago

jmmortega commented 1 year ago

Description

We catch this error using ANRWatchDog https://github.com/nwestfall/Xamarin.ANRWatchDog in production and the same AppCenter report this custom crash. This it's the stacktrace:

{ "$id": "1", "ExtraStackTrace": " at System.Environment.get_StackTrace () [0x00000] in :0 \n at Project.Utils.Logger.PrepareException (System.Exception exception, System.Object[] messageProperties, System.String callerName, System.String callerFilePath, System.Int32 callerLineNumber) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Utils.Log (System.Exception exception, System.Boolean showToUser, System.Int32 timeShowMessageMs, System.Object[] messageProperties, System.String callerName, System.String callerFilePath, System.Int32 callerLineNumber) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Droid.Services.ANRWatchDogService.ANRListener+<>cDisplayClass0_0.b__0 () [0x00000] in <3884ddcc9e8c4e0ca33687178f27fa32>:0 \n at Project.Utils.SecureCalls.SecureCall (System.Action invoke, System.Action`1[T] extraCallInException, System.Action extraCallInFinally, System.Boolean showToUser, System.Boolean reportToLog) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Droid.Services.ANRWatchDogService.ANRListener.OnAppNotResponding (Xamarin.ANRWatchDog.ANRError error) [0x00000] in <3884ddcc9e8c4e0ca33687178f27fa32>:0 \n at Xamarin.ANRWatchDog.ANRWatchDog.Run () [0x00000] in <52a15e0883994e2e9d7036c2bcaa1ded>:0 \n at Java.Lang.Thread.n_Run (System.IntPtr jnienv, System.IntPtr nativethis) [0x00000] in <71103707bc754834b2ad65a04606167c>:0 \n at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00000] in <71103707bc754834b2ad65a04606167c>:0 ", "Error": { "$id": "2", "ApplicationNotRespondingStackTrace": "\n --- End of managed Xamarin.ANRWatchDog.ANRError stack trace ---\ncrc6426ad4e10c8cd0a92.ANRError: Application Not Responding\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: main (state = RUNNABLE)\n\tat mono.java.lang.RunnableImplementor.n_run(Native Method)\n\tat mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)\n\tat android.os.Handler.handleCallback(Handler.java:938)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loopOnce(Looper.java:201)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.app.ActivityThread.main(ActivityThread.java:7900)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: ConnectivityThread (state = RUNNABLE)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:335)\n\tat android.os.Looper.loopOnce(Looper.java:161)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.os.HandlerThread.run(HandlerThread.java:67)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: FinalizerDaemon (state = WAITING)\n\tat java.lang.Object.wait(Native Method)\n\tat java.lang.Object.wait(Object.java:442)\n\tat java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:203)\n\tat java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:224)\n\tat java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:300)\n\tat java.lang.Daemons$Daemon.run(Daemons.java:140)\n\tat java.lang.Thread.run(Thread.java:1012)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: WifiManagerThread (state = RUNNABLE)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:335)\n\tat android.os.Looper.loopOnce(Looper.java:161)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.os.HandlerThread.run(HandlerThread.java:67)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: ScrollPolicy (state = RUNNABLE)\n\t... 5 more\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: FramePolicy (state = RUNNABLE)\n\t... 5 more\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: |ANR-WatchDog| (state = RUNNABLE)\n\tat dalvik.system.VMStack.getThreadStackTrace(Native Method)\n\tat java.lang.Thread.getStackTrace(Thread.java:1841)\n\tat java.lang.Thread.getAllStackTraces(Thread.java:1909)\n\tat crc6426ad4e10c8cd0a92.ANRWatchDog.n_run(Native Method)\n\tat crc6426ad4e10c8cd0a92.ANRWatchDog.run(ANRWatchDog.java:39)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: Okio Watchdog (state = WAITING)\n\tat java.lang.Object.wait(Native Method)\n\tat java.lang.Object.wait(Object.java:442)\n\tat java.lang.Object.wait(Object.java:568)\n\tat com.android.okhttp.okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:313)\n\tat com.android.okhttp.okio.AsyncTimeout.access$000(AsyncTimeout.java:42)\n\tat com.android.okhttp.okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:288)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: FinalizerWatchdogDaemon (state = TIMED_WAITING)\n\tat java.lang.Thread.sleep(Native Method)\n\tat java.lang.Thread.sleep(Thread.java:450)\n\tat java.lang.Thread.sleep(Thread.java:355)\n\tat java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos(Daemons.java:438)\n\tat java.lang.Daemons$FinalizerWatchdogDaemon.waitForProgress(Daemons.java:480)\n\tat java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:369)\n\tat java.lang.Daemons$Daemon.run(Daemons.java:140)\n\tat java.lang.Thread.run(Thread.java:1012)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: AppCenter.Looper (state = RUNNABLE)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:335)\n\tat android.os.Looper.loopOnce(Looper.java:161)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.os.HandlerThread.run(HandlerThread.java:67)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: launch (state = RUNNABLE)\n\t... 5 more\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: AsyncTask #19 (state = WAITING)\n\tat jdk.internal.misc.Unsafe.park(Native Method)\n\tat java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)\n\tat java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:461)\n\tat java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:361)\n\tat java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:922)\n\tat java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1063)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1123)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)\n\tat java.lang.Thread.run(Thread.java:1012)\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: ReferenceQueueDaemon (state = WAITING)\n\tat java.lang.Object.wait(Native Method)\n\tat java.lang.Object.wait(Object.java:442)\n\tat java.lang.Object.wait(Object.java:568)\n\tat java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:232)\n\tat java.lang.Daemons$Daemon.run(Daemons.java:140)\n\t... 1 more\nCaused by: crc6426ad4e10c8cd0a92.ANRErrorThreadTraceThread: queued-work-looper (state = RUNNABLE)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:335)\n\tat android.os.Looper.loopOnce(Looper.java:161)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.os.HandlerThread.run(HandlerThread.java:67)\n", "Message": "Serialized Application Not Responding", "Data": {}, "InnerException": null, "StackTrace": null, "HelpLink": null, "Source": null, "HResult": -2146233088 }, "ExceptionToProperties": { "Message": "Serialized Application Not Responding", "StackTrace": null, "Source": null, "InnerException": null, "ExtraStackTrace": " at System.Environment.get_StackTrace () [0x00000] in :0 \n at Project.Utils..PrepareException (System.Exception exception, System.Object[] messageProperties, System.String callerName, System.String callerFilePath, System.Int32 callerLineNumber) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Utils.Logger.Log (System.Exception exception, System.Boolean showToUser, System.Int32 timeShowMessageMs, System.Object[] messageProperties, System.String callerName, System.String callerFilePath, System.Int32 callerLineNumber) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Droid.Services.ANRWatchDogService.ANRListener+<>cDisplayClass0_0.b__0 () [0x00000] in <3884ddcc9e8c4e0ca33687178f27fa32>:0 \n at Project.Utils.SecureCalls.SecureCall (System.Action invoke, System.Action`1[T] extraCallInException, System.Action extraCallInFinally, System.Boolean showToUser, System.Boolean reportToLog) [0x00000] in <52d50126f704452c93dd4755842cb2cd>:0 \n at Project.Droid.Services.ANRWatchDogService.ANRListener.OnAppNotResponding (Xamarin.ANRWatchDog.ANRError error) [0x00000] in <3884ddcc9e8c4e0ca33687178f27fa32>:0 \n at Xamarin.ANRWatchDog.ANRWatchDog.Run () [0x00000] in <52a15e0883994e2e9d7036c2bcaa1ded>:0 \n at Java.Lang.Thread.n_Run (System.IntPtr jnienv, System.IntPtr nativethis) [0x00000] in <71103707bc754834b2ad65a04606167c>:0 \n at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00000] in <71103707bc754834b2ad65a04606167c>:0 " }, "CallerName": "OnAppNotResponding", "FilePath": "/Users/runner/work/1/s/Project.Droid/Services/ANRWatchDogService/ANRListener.cs", "CallerLineNumber": 31, "ExtraProperties": null, "EventLevel": 4, "ExtraPropertiesForError": { "CallerName": "OnAppNotResponding", "FilePath": "/Users/runner/work/1/s/Project.Droid/Services/ANRWatchDogService/ANRListener.cs", "CallerLineNumber": "31" }, "ConvertExtraProperties": {} }

Repro Steps

I not pretty sure because happens in production, it's true, the application working in a scenario that connection should be compromised. Large places with Access points, large times in offline.

I'm trying to reproduce locally, sending a lot of request to AppCenter concurrently and trying to reproduce the same scenario, low connection issues, offline situations...

All that I know it's seems something that block inside of the AppCenter.Looper.

Any help to improve the situation will be appreciated. Thanks!

Details

  1. Which SDK version are you using? -5.0.1
  2. Which OS version did you experience the issue on?
    • Android 10, Android 11 and Android 12
  3. What device version did you see this error on? Were you using an emulator or a physical device?
    • Several devices
  4. What third party libraries are you using?
    • Use the AppCenter nuget Xamarin flavour
  5. Please enable verbose logging for your app using AppCenter.setLogLevel(Log.VERBOSE) before your call to AppCenter.start(...) and include the logs here: I can't because it's ANR error in production
AnatolyPristensky commented 1 year ago

Hello @jmmortega, could you please share more information? How often the issue is appearing and in what moment? Is it appears during the start of app, or during minimising or closing, or switching activities?

Any other additional information will be helpful.

jmmortega commented 1 year ago

Hello @AnatolyPristensky that I said, it's an error that track in production. Seems happens in anytime, in any place meanwhile running.

AnatolyPristensky commented 1 year ago

@jmmortega unfortunately, there are not enough information (or DemoApp) on how to reproduce it, so let's wait for another cases of this issue and more information.

DmitriyKirakosyan commented 6 months ago

As we do not have plans to fix this bug in the next year, I'm closing the issue.