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

未关闭
#8,052 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
活跃
技术栈
android, java
领域
mobile-dev

调研方向

先从 com.google.firebase.crashlytics.internal.common.Utils.awaitEvenIfOnMainThread 和 CrashlyticsController.handleUncaughtException 开始,然后检查 CrashlyticsUncaughtExceptionHandler。查看 Android 11 的堆栈跟踪以及与 com.huawei.hms.network.embedded.t4 的交互;报告中没有复现步骤或指定名称的测试。完成标准是确定此次等待是否会导致报告中的 ANR,并记录或测试由此产生的行为。

由索引模型根据 Issue 内容生成。

描述

api: crashlytics
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?
主要语言
Java
星标
2.6k
派生
733
平均合并
2 天 15 小时
30 天内合并 PR
72

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-android-sdk 的其他 Issue

查看 firebase/firebase-android-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。