MediaGalleryPreviewActivity crashes on Android 13: NPE Class.isInterface() in typed getParcelableExtra

Đang mở Phù hợp với người mới
#6,982 1 bình luận 0 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, kotlin
Lĩnh vực
mobile

Hướng nghiên cứu

Mở MediaGalleryPreviewActivity.kt và kiểm tra các thao tác đọc Parcelable có kiểu của Intent và Bundle được mô tả trong báo cáo. So sánh cách xử lý cấp API của chúng với IntentCompat.getParcelableExtra và BundleCompat.getParcelable, sau đó kiểm tra hành vi tương thích của AndroidX trên API 33. Issue được hoàn tất khi bản xem trước mở trên Android 13 mà không gặp sự cố đã báo cáo và các thao tác đọc trạng thái đã lưu sử dụng getter tương thích.

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

Mô tả

Describe the bug
MediaGalleryPreviewActivity crashes on Android 13 (API 33) while reading its intent extras, with no app code in the stack:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference
  at java.lang.Class.isAssignableFrom(Class.java:874)
  at android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4875)
  at android.os.Parcel.readParcelableInternal(Parcel.java:4788)
  at android.os.Parcel.readValue(Parcel.java:4554)
  at android.os.Parcel.readValue(Parcel.java:4334)
  at android.os.Parcel.-$$Nest$mreadValue(Unknown Source)
  at android.os.Parcel$LazyValue.apply(Parcel.java:4432)
  at android.os.Parcel$LazyValue.apply(Parcel.java:4391)
  at android.os.BaseBundle.getValueAt(BaseBundle.java:394)
  at android.os.BaseBundle.getValue(BaseBundle.java:374)
  at android.os.BaseBundle.getValue(BaseBundle.java:357)
  at android.os.BaseBundle.get(BaseBundle.java:696)
  at android.os.Bundle.getParcelable(Bundle.java:947)
  at android.content.Intent.getParcelableExtra(Intent.java:8930)
  at io.getstream.chat.android.compose.ui.attachments.preview.MediaGalleryPreviewActivity.onCreate$lambda$13(MediaGalleryPreviewActivity.kt)
  at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:122)
  ...

The private helper Intent.getParcelable<T>(key) in MediaGalleryPreviewActivity switches to the typed getParcelableExtra(key, T::class.java) from Build.VERSION_CODES.TIRAMISU. The typed Intent/Bundle getters have a known platform bug on API 33 that throws exactly this NPE inside Parcel.readParcelableCreatorInternal; it is fixed in API 34. That is why androidx.core.content.IntentCompat.getParcelableExtra / BundleCompat.getParcelable only use the typed API from UPSIDE_DOWN_CAKE and fall back to the untyped call on 33.

Suggested fix: replace the helper with IntentCompat.getParcelableExtra(intent, key, T::class.java) (or raise the version check to Build.VERSION_CODES.UPSIDE_DOWN_CAKE). The same pattern applies to the Bundle reads from savedInstanceState.

The file is identical in 7.13.0, 7.18.0 and develop, so the crash is still present in the latest release.

SDK version

  • stream-chat-android-compose 7.13.0 (code unchanged up to 7.18.0 / develop)

To Reproduce
Not reproducible on demand: it is a platform race in the Android 13 typed Parcel API. Observed in production:

  1. Open a channel containing an image attachment
  2. Tap the image to open MediaGalleryPreviewActivity
  3. The activity crashes during the first composition

Expected behavior
The media gallery preview opens without crashing on Android 13.

Device:

  • Vendor and model: Xiaomi Redmi Note 11 (2201117TY)
  • Android version: 13 (TKQ1.221114.001)

Screenshots
N/A

Ngôn ngữ chính
Kotlin
Star
1.7k
Fork
321
Merge trung bình
19 giờ 57 phút
Pull request đã merge (30 ngày)
167

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 GetStream/stream-chat-android

Tất cả issue của GetStream/stream-chat-android

Issue tương tự

Thêm issue về Kotlin

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.