Skip to content

[Crashlytics] ANR on main thread due to awaitEvenIfOnMainThread when third-party SDKs are present in the UncaughtExceptionHandler chain #8052

@AntonMishanin

Description

@AntonMishanin

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions