Skip to content

AttachmentMediaActivity crashes in onStart when the url extra is null #6762

Description

@stevePanella

Describe the bug
AttachmentMediaActivity crashes with a NullPointerException when it's started without a url extra. onCreate catches the null url, logs "This file can't be displayed", and shows the playback error, but binding is already initialized by then. So onStart gets past its ::binding.isInitialized check and calls Uri.parse(url) with null.

java.lang.NullPointerException: uriString
    at android.net.Uri$StringUri.<init>(Uri.java:496)
    at android.net.Uri$StringUri.<init>(Uri.java:486)
    at android.net.Uri.parse(Uri.java:458)
    at io.getstream.chat.android.ui.feature.gallery.AttachmentMediaActivity.onStart(AttachmentMediaActivity.kt:95)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1674)
    at android.app.Activity.performStart(Activity.java:8018)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3469)

The same code is still in 7.13.0 and on develop.

SDK version

  • 7.3.0 (also present in 7.13.0)

To Reproduce
We don't know the exact user steps that end up with a null url, since AttachmentDestination passes assetUrl ?: "". You can hit the crash directly by starting the activity without the extra:

  1. On an emulator: adb root, then
    adb shell am start -n <your.app.id>/io.getstream.chat.android.ui.feature.gallery.AttachmentMediaActivity --es type video
  2. See the crash in onStart

Expected behavior
The activity doesn't crash when the url extra is null.

Device:

  • Vendor and model: Honor HRY-LX1T, OnePlus 8 Pro, OnePlus A0001
  • Android version: 11

Screenshots
N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions