Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException #2025

Open
1 task
konstant2016 opened this issue Jan 8, 2025 · 4 comments
Open
1 task

java.lang.NullPointerException #2025

konstant2016 opened this issue Jan 8, 2025 · 4 comments
Assignees

Comments

@konstant2016
Copy link

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 [email protected] after filing this issue.
@icbaker
Copy link
Collaborator

icbaker commented Jan 10, 2025

I played the provided stream in the demo app and it didn't crash.

Does this issue always occur for you, or only occasionally? Please can you provide more info about how we can reproduce the problem? Without this, it's hard to investigate any further.

The stack trace looks like HlsSampleStreamWrapper.onUpstreamFormatChanged was called (should be on the loading thread), and posted a call to HlsSampleStreamWrapper.maybeFinishPrepare to the playback thread. By the time this call executed, it seems the HlsMediaPeriod.mediaPeriodCallback field has become null, which means the period has been released.

@konstant2016
Copy link
Author

konstant2016 commented Jan 10, 2025 via email

@konstant2016
Copy link
Author

感谢您的回复
这个问题出现的概率非常低,到目前为止我只遇到这一次crash,无法再复现了

I played the provided stream in the demo app and it didn't crash.

Does this issue always occur for you, or only occasionally? Please can you provide more info about how we can reproduce the problem? Without this, it's hard to investigate any further.

The stack trace looks like HlsSampleStreamWrapper.onUpstreamFormatChanged was called (should be on the loading thread), and posted a call to HlsSampleStreamWrapper.maybeFinishPrepare to the playback thread. By the time this call executed, it seems the HlsMediaPeriod.mediaPeriodCallback field has become null, which means the period has been released.

感谢您的回复
这个问题出现的概率非常低,到目前为止我只遇到这一次crash,无法再复现了

@icbaker icbaker assigned tianyif and unassigned icbaker Jan 10, 2025
@icbaker
Copy link
Collaborator

icbaker commented Jan 10, 2025

Thanks for the reply - I'm just including your reply here after I ran it through google translate:

thanks for your reply
The probability of this problem occurring is very low. So far I have only encountered this crash and it cannot be reproduced again.

Given that this happens with very low probability I'm afraid it's hard for us to investigate. I'll assign it to the HLS expert to see if there's an obvious race condition problem with the way HLS periods are prepared and released.

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

No branches or pull requests

4 participants