ANR during FirebaseInitProvider.onCreate - SimpleArrayMap/ContainerHelpersKt class initialization

Đang mở
#7,876 11 bình luận 5 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
android, firebase, java
Lĩnh vực
mobile, performance

Hướng nghiên cứu

Bắt đầu bằng cách truy vết FirebaseInitProvider.onCreate qua quá trình khởi tạo lớp FirebaseApp, tập trung vào việc tải SimpleArrayMap và ContainerHelpersKt trên main thread như đã được báo cáo. So sánh các startup trace từ những thiết bị cấp thấp bị ảnh hưởng và kiểm tra đường dẫn khởi tạo của firebase-common; công việc được xem là hoàn tất khi xác lập được nguyên nhân có thể tái hiện hoặc một biện pháp giảm thiểu được hỗ trợ rõ ràng, với độ bao phủ cho hành vi startup liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

api: core needs-attention
[READ] Step 1: Are you in the right place?
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the
    firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories,
    reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
  • Android Studio version: Android Studio Otter | 2025.2.1 Patch 1
  • Firebase Component: Firebase Core (firebase-common)
  • Component version: BOM 34.3.0
[REQUIRED] Step 3: Describe the problem

We are seeing ANRs during app cold start caused by slow class static initialization (<clinit>) in FirebaseApp triggered by FirebaseInitProvider.onCreate() on the main thread. The main thread is blocked performing class loading/verification of androidx.collection.SimpleArrayMap and ContainerHelpersKt with no lock contention and all other threads are idle.
This impacts lower-end devices during cold start. Since FirebaseInitProvider runs as a ContentProvider it blocks the entire app startup path before Application.onCreate() is even called.
We are already on the latest androidx.collection (1.5.0 resolved).

Steps to reproduce:

Cannot reproduce locally. Observed in production via Crashlytics on lower-end devices during cold start.

"main" tid=1 Runnable
  at androidx.collection.SimpleArrayMap.<init> (SourceFile:65354)
  at com.google.firebase.FirebaseApp.<clinit> (SourceFile:65354)
  at com.google.firebase.provider.FirebaseInitProvider.onCreate (SourceFile:65348)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2648)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2616)
  at com.google.firebase.provider.FirebaseInitProvider.attachInfo (SourceFile:65352)
  at android.app.ActivityThread.installProvider (ActivityThread.java:8490)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:8003)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7667)

Stack trace 2:

  at androidx.collection.internal.ContainerHelpersKt.<clinit> (SourceFile:65354)
  at androidx.collection.SimpleArrayMap.<init> (SourceFile:65354)
  at com.google.firebase.FirebaseApp.<clinit> (SourceFile:65354)
  at com.google.firebase.provider.FirebaseInitProvider.onCreate (SourceFile:65348)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2648)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2616)
  at com.google.firebase.provider.FirebaseInitProvider.attachInfo (SourceFile:65352)
  at android.app.ActivityThread.installProvider (ActivityThread.java:8490)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:8003)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7667)

In both cases, all other threads (binder, daemon, SharedPreferences, etc.) are idle or in waiting state — no lock contention is involved.

What happened? How can we make the problem occur? This could be a description, log/console output,
etc.

Device & OS breakdown

Android versions: Android 15 (SDK 35), Android 16 Beta (SDK 36)
Visibility: Foreground
Top affected devices:

  • realme RE6095
  • realme RE6054
  • realme RE58BC
  • realme RE5C9F
Relevant Code:
// No app code involved. ANR occurs before Application.onCreate() 
// during ContentProvider initialization triggered by the system.
// FirebaseInitProvider is auto-merged into the manifest by the Firebase SDK.
Image
Ngôn ngữ chính
Java
Star
2.6k
Fork
733
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
72

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-android-sdk

Tất cả issue của firebase/firebase-android-sdk

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.