google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.02k forks source link

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.source.ads.AdsMediaSource$ComponentListener.release()' on a null object reference #5347

Closed Divya015 closed 5 years ago

Divya015 commented 5 years ago

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.source.ads.AdsMediaSource$ComponentListener.release()' on a null object reference

We are using exoplayer 2.7.1 version, observed the below crash at random scenarios. Please look into it. MediaSource Object creation : 1)Mediasource mediaSource = buildMediaSource(uris, extensions);

2)private MediaSource buildMediaSource(Uri uri, String overrideExtension) { int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri) : Util.inferContentType("." + overrideExtension); switch (type) { case C.TYPE_SS: return new SsMediaSource(uri, buildDataSourceFactory(false), new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger); case C.TYPE_DASH: return new DashMediaSource(uri, buildDataSourceFactory(false), new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger); case C.TYPE_HLS: return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger); case C.TYPE_OTHER: return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, eventLogger); default: { throw new IllegalStateException("Unsupported type: " + type); } } }

3)mediaSourcewithAd = createAdsMediaSource(mediaSource, Uri.parse(adurl)); 4)player.prepare(mediaSourcewithAd,false, false);

andrewlewis commented 5 years ago

Are you releasing the AdsMediaSource yourself? I think that could cause this error, but it sounds strange that the issue would be seen only occasionally. See also the related discussion in #4974.

Divya015 commented 5 years ago

I observed the crash in one scenario. Scenario : We have player recommendations while playing any video, if i rigorously keep clicking on playable recommendation items observed the crash.

For each playable item click we release the player, create mediasource of new item and play.(releasing adsLoader before creating admediasource)

It is same as discussion #4974 due to prepareInternal -> resetInternal-> releaseMediaSource.

How can i address this issue?

andrewlewis commented 5 years ago

@Divya015 When I looked at #4974 before I couldn't see a path that could allow this to happen. Could you make a minimal project that reproduces the issue using the latest version of ExoPlayer, and share a link to it here? Or if you can spot a sequence of events that causes this to happen please describe it. Thanks in advance.

ojw28 commented 5 years ago

Closing due to lack of further information. We'll reopen the issue if further information is provided.