androidx / androidx/media

java.lang.NullPointerException

Open
#2,025 4 comments 1 reaction 1 assignee View on GitHub

Nobody has claimed this yet.

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

Description

Version

Media3 1.5.0

More version details

java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.media3.exoplayer.source.MediaPeriod$Callback.onPrepared(androidx.media3.exoplayer.source.MediaPeriod)' on a null object reference
at androidx.media3.exoplayer.hls.HlsMediaPeriod$SampleStreamWrapperCallback.onPrepared(HlsMediaPeriod.java:942)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.maybeFinishPrepare(HlsSampleStreamWrapper.java:1332)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper.$r8$lambda$n_MpjkbSugVnCnE8WpH6RrpZ5gA(Unknown Source:0)
at androidx.media3.exoplayer.hls.HlsSampleStreamWrapper$$ExternalSyntheticLambda2.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.os.HandlerThread.run(HandlerThread.java:67)

Devices that reproduce the issue

huawei C3 Android 10

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No

Reproduction steps

使用代码如下:

fun getExoPlayerInstance(context: Context): ExoPlayer {
    val application = context.applicationContext
    val bandwidthMeter = DefaultBandwidthMeter.getSingletonInstance(application)
    val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory()
    val trackSelector = DefaultTrackSelector(application, videoTrackSelectionFactory)
    val builder = ExoPlayer.Builder(application)
    builder.setBandwidthMeter(bandwidthMeter)
    val renderFactory = DefaultRenderersFactory(application)
    val enableSoftDecode = PlayerManager.getProvider().enableSoftwareMediaDecode()
    renderFactory.setEnableDecoderFallback(enableSoftDecode)
    builder.setRenderersFactory(renderFactory)
    builder.setTrackSelector(trackSelector)
    builder.setReleaseTimeoutMs(3000)
    builder.setLoadControl(DefaultLoadControl())
    builder.setSeekParameters(SeekParameters.DEFAULT)
    return builder.build()
}

private fun buildHlsMediaSource(uri: Uri): MediaSource {
    val factory: DataSource.Factory = DefaultHttpDataSource.Factory().apply {
        setAllowCrossProtocolRedirects(true)
    }
    val mediaItem = MediaItem.Builder()
        .setUri(uri)
        .build()
    return HlsMediaSource.Factory(factory).createMediaSource(mediaItem)
}
Expected result

功能逻辑正常

Actual result

报了一个java.lang.NullPointerException,概率非常低,只遇到过一次,无法复现

Media

https://hls.media.yangcong345.com/fullHigh/fullHigh_8ff4741e-3b25-4a25-baaf-8f01bb5d77c7.m3u8

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.