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

オープン 初心者向け
#6,982 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, kotlin
領域
mobile

調査の方向性

MediaGalleryPreviewActivity.ktを開き、レポートに記載されたIntentとBundleの型指定されたParcelable読み取りを調べます。APIレベルの処理をIntentCompat.getParcelableExtraおよびBundleCompat.getParcelableと比較し、API 33でのAndroidXの互換動作を確認します。報告されたクラッシュが発生せずにAndroid 13でプレビューが開き、保存状態の読み取りに互換性のあるgetterが使われれば、issueは完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Kotlin
スター
1.7k
フォーク
321
平均マージ
19時間 57分
マージ済み PR(30日)
167

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GetStream/stream-chat-android のほかの issue

GetStream/stream-chat-android の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。