MediaGalleryPreviewActivity crashes on Android 13: NPE Class.isInterface() in typed getParcelableExtra
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
打开MediaGalleryPreviewActivity.kt,检查报告中描述的Intent和Bundle的类型化Parcelable读取。将它们对API级别的处理与IntentCompat.getParcelableExtra和BundleCompat.getParcelable进行比较,然后检查AndroidX在API 33上的兼容行为。当预览能在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-compose7.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:
- Open a channel containing an image attachment
- Tap the image to open
MediaGalleryPreviewActivity - 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 分钟
- 30 天内合并 PR
- 167
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GetStream/stream-chat-android 的其他 Issue
-
feature request
难度 3/5 1-2 天 新手友好度 65/100
GetStream/stream-chat-android#6556 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Add Sort Order Support for Media and Files Attachments Lists in Channel Info可能重新可做 关联的 PR 已关闭且未合并。 未关闭feature request
难度 4/5 3-5 天 新手友好度 55/100
GetStream/stream-chat-android#6359 ·
维护者通常 1 天内回复
-
feature request
难度 3/5 1-2 天 新手友好度 38/100
GetStream/stream-chat-android#6243 ·
维护者通常 1 天内回复
-
Unable to wrap ChannelList height due to internal LazyColumn .fillMaxSize()可能重新可做 @Ahmetkaragunlu 于 19 天前认领,目前没有进行中的 PR。 未关闭compose feature request
难度 4/5 3-5 天 新手友好度 35/100
GetStream/stream-chat-android#5612 · 4 条评论 ·
维护者通常 1 天内回复
-
core feature request
难度 4/5 3-5 天 新手友好度 25/100
GetStream/stream-chat-android#5279 ·
维护者通常 1 天内回复
查看 GetStream/stream-chat-android 的全部 Issue
相似的 Issue
-
unconfirmed
难度 2/5 1-3 小时 新手友好度 72/100
thunderbird/thunderbird-android#11893 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
Droid-Deck/DroidDeck#2198 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
world-federation-of-advertisers/cross-media-measurement#4846 ·
维护者通常 1 天内回复
-
autoteam community connectors/destination/mssql connectors/source/hubspot team/use
难度 2/5 1-3 小时 新手友好度 77/100
airbytehq/airbyte#91201 · 1 条评论 ·
维护者通常 1 天内回复
-
bug javascript
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复