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

Abierto Apto para principiantes
#6,982 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin
Área
mobile

Línea de trabajo

Abre MediaGalleryPreviewActivity.kt e inspecciona las lecturas tipadas de Parcelable de Intent y Bundle descritas en el informe. Compara cómo gestionan los niveles de API con IntentCompat.getParcelableExtra y BundleCompat.getParcelable, y luego comprueba el comportamiento de compatibilidad de AndroidX para API 33. El issue está resuelto cuando la vista previa se abre en Android 13 sin el cierre inesperado reportado y las lecturas del estado guardado usan getters compatibles.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Kotlin
Estrellas
1.7k
Forks
321
Merge medio
19 h 57 min
PR fusionados (30 d)
167

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de GetStream/stream-chat-android

Todos los issues de GetStream/stream-chat-android

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.