firebase / firebase/firebase-android-sdk
[Crashlytics] ANR on main thread due to awaitEvenIfOnMainThread when third-party SDKs are present in the UncaughtExceptionHandler chain
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 710
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 31
Description
### Environment:
- Firebase Component: firebase-crashlytics
- Component version: com.google.firebase:firebase-crashlytics:20.0.4
- Android versions: 100% android 11
- Devices: 80% Samsung, Xiaomi, Oppo
- Device state: 100% background
The project includes HMS push notifications, location. But we don't use hms crashlytics or hms analytics.
### Describe the problem
We're seeing ANRs on the main thread that occur during crash handling. The stack trace consistently points to Crashlytics waiting inside awaitEvenIfOnMainThread:
```
main (timed waiting):tid=1 systid=12425
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.CountDownLatch.await(CountDownLatch.java:278)
at com.google.firebase.crashlytics.internal.common.Utils.awaitEvenIfOnMainThread(Utils.java:62)
at com.google.firebase.crashlytics.internal.common.CrashlyticsController.handleUncaughtException(CrashlyticsController.java:262)
at com.google.firebase.crashlytics.internal.common.CrashlyticsController.handleUncaughtException(CrashlyticsController.java:181)
at com.google.firebase.crashlytics.internal.common.CrashlyticsController$1.onUncaughtException(CrashlyticsController.java:168)
at com.google.firebase.crashlytics.internal.common.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:54)
at com.huawei.hms.network.embedded.t4.uncaughtException(:141)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.Thread.dispatchUncaughtException(Thread.java:2203)
```
Also I can see com.huawei.hms.network.embedded.t4.uncaughtException
#### Steps to reproduce:
Unknown
#### Question
1. Now awaitEvenIfOnMainThread is @Deprecated. What are your plans about this function?
2. Could this function affect ANR?
Contributor guide
Assessment
This issue has not been assessed yet.