androidx / androidx/media

androidx.media3.cast.CastPlayer: NullPointerException DefaultMediaItemConverter.toMediaItem 88

Open
#1,961 3 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Dec 9, 2024.

bug
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.4.1

More version details

No response

Devices that reproduce the issue

Can't reproduce, get crash via firebase crashlytics

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps
  1. Take an application with Cast implementation without androidx.media3.cast.CastPlayer
  2. Start cast
  3. Take an application with androidx.media3.cast.CastPlayer
  4. Start cast too
Expected result

The media play successfully

Actual result

java.lang.NullPointerException

Media

Attached a screenshot of the crash from firebase crashlytics
screenshot-2-4

couldn't reproduce the crash
use DefaultMediaItemConverter
I search existing issues, but can't find related bug in media3 or ExoPlayer repo
I find the same bug in Conned-SDK-Android - https://github.com/ConnectSDK/Connect-SDK-Android/issues/376
Looks like the crash has been reproduced in Jun 9, 2023 (exoplayer2.ext.cast.CastPlayer)

Do you have any ideas on how to fix this?
Do you need any additional information?
I can see comment in DefaultMediaItemConverter, mediaQueueItem came from toMediaQueueItem() so the custom JSON data must be set.
When is getCustomData expected to be null?

I was pondering a decision, but it confuses me that it costs checking and an exception is purposefully thrown Assertions.checkNotNull
What do you think about this fix?

if (mediaInfo.getCustomData() == null) {
            return MediaItem.EMPTY;
}

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.