NewPipe icon indicating copy to clipboard operation
NewPipe copied to clipboard

Crash when player service is being stopped in some cases (NullPointerException)

Open InconsolableCellist opened this issue 1 year ago • 7 comments
trafficstars

Checklist

  • [X] I am able to reproduce the bug with the latest version given here: CLICK THIS LINK.
  • [X] I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • [X] I have read the FAQ and my problem isn't listed.
  • [X] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • [X] This issue contains only one bug.
  • [X] I have read and understood the contribution guidelines.

Affected version

0.27.0

Steps to reproduce the bug

  1. Begin playing a video
  2. Switch from WiFi to 5G or vice versa. Wait a moment

Expected behavior

Video continues to play

Actual behavior

Video stops playing and NewPipe opens up (even when playing in the background) with the guru meditation screen.

I'll need to close and open the app to recover. Also sometimes my position in the video will be lost, so even going to it through the History tab won't allow me to resume where I left off. That makes it even more annoying.

Screenshots/Screen recordings

No response

Logs

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US
  • Service: none
  • Version: 0.27.0
  • OS: Linux Android 13 - 33
Crash log

java.lang.RuntimeException: Unable to stop service org.schabi.newpipe.player.PlayerService@1ac624e: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.setCustomActionProviders(com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector$CustomActionProvider[])' on a null object reference
	at android.app.ActivityThread.handleStopService(ActivityThread.java:5285)
	at android.app.ActivityThread.-$$Nest$mhandleStopService(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2454)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8772)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.setCustomActionProviders(com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector$CustomActionProvider[])' on a null object reference
	at org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi.updateMediaSessionActions(MediaSessionPlayerUi.java:215)
	at org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi.onMetadataChanged(MediaSessionPlayerUi.java:282)
	at org.schabi.newpipe.player.Player.lambda$updateMetadataWith$22(Player.java:1801)
	at org.schabi.newpipe.player.Player.$r8$lambda$6LL1ynLVHUrHxxol0bvWL1Rn_TU(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda47.accept(R8$$SyntheticClass:0)
	at j$.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source:19)
	at j$.util.stream.ReferencePipeline$Head.forEachOrdered(Unknown Source:10)
	at org.schabi.newpipe.player.ui.PlayerUiList.call(PlayerUiList.java:88)
	at org.schabi.newpipe.player.Player.updateMetadataWith(Player.java:1801)
	at org.schabi.newpipe.player.Player.lambda$onEvents$13(Player.java:1293)
	at org.schabi.newpipe.player.Player.$r8$lambda$5dalatdJw7zsnq99HOZvtSHTxZo(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda37.accept(R8$$SyntheticClass:0)
	at j$.util.Optional.ifPresent(Unknown Source:4)
	at org.schabi.newpipe.player.Player.lambda$onEvents$14(Player.java:1287)
	at org.schabi.newpipe.player.Player.$r8$lambda$67JZJPUrqqIwv2qPVBiXIeF-1Rs(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda9.accept(R8$$SyntheticClass:0)
	at j$.util.Optional.ifPresent(Unknown Source:4)
	at org.schabi.newpipe.player.Player.onEvents(Player.java:1265)
	at com.google.android.exoplayer2.ExoPlayerImpl.lambda$new$0(ExoPlayerImpl.java:266)
	at com.google.android.exoplayer2.ExoPlayerImpl.$r8$lambda$FaN7Odt_OJn5xWFlmhnR2OmiNMg(ExoPlayerImpl.java:0)
	at com.google.android.exoplayer2.ExoPlayerImpl$$ExternalSyntheticLambda1.invoke(R8$$SyntheticClass:0)
	at com.google.android.exoplayer2.util.ListenerSet$ListenerHolder.release(ListenerSet.java:320)
	at com.google.android.exoplayer2.util.ListenerSet.remove(ListenerSet.java:183)
	at com.google.android.exoplayer2.ExoPlayerImpl.removeListener(ExoPlayerImpl.java:1641)
	at org.schabi.newpipe.player.Player.destroyPlayer(Player.java:573)
	at org.schabi.newpipe.player.Player.destroy(Player.java:600)
	at org.schabi.newpipe.player.PlayerService.cleanup(PlayerService.java:150)
	at org.schabi.newpipe.player.PlayerService.onDestroy(PlayerService.java:145)
	at android.app.ActivityThread.handleStopService(ActivityThread.java:5265)
	... 9 more


Affected Android/Custom ROM version

No response

Affected device model

Samsung Galaxy ZFold 4

Additional information

Phone: SM-F936U1 One UI 5.0 Android 13 Kernel Version: 5.10.81-android12-9-25407272-abF936U1UEU1BVKB

This is a de-Googled phone, so it doesn't run Google Play Services, which has been put to deep sleep via adb.

Maybe you can add a null check here: https://github.com/TeamNewPipe/NewPipe/blob/879d7a24f05ab06510be249f2f3b5109f7c89dcc/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java#L215

private void updateMediaSessionActions() {
    if (sessionConnector == null) {
        // log...
        return;
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
        return;
    }

    // ...
}

Or maybe it's clear to you why https://github.com/TeamNewPipe/NewPipe/blob/879d7a24f05ab06510be249f2f3b5109f7c89dcc/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java#L280 can be called when init apparently wasn't called, or sessionConnector is somehow being unset?

This happens very often to me, basically whenever I leave the house while playing a video in the background, or entering.

InconsolableCellist avatar May 02 '24 00:05 InconsolableCellist

Is that the error you get each time? This looks like a duplicate of #10097, but your error is different,

opusforlife2 avatar May 02 '24 16:05 opusforlife2

No, that's completely different and is very likely a 0.27.0 regression related to media notification actions changes.

I can reproduce this issue if a playback error occurs when playing a content in the main player (so it is closed due to the error), while the player service is being stopped.

AudricV avatar May 02 '24 18:05 AudricV

I got the same error, but in a different situation. I was watching a video and wanted to play another one. I clicked on the other one. Then the message appeared. After clicking away the error message, I had to restart NewPipe.

Smartphone: Fairphone 4 (CalyxOS 5.6.3, Android 14) NewPipe version 0.27.0

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US_#u-fw-mon-mu-celsius
  • Service: none
  • Version: 0.27.0
  • OS: Linux Android 14 - 34
Crash log

java.lang.RuntimeException: Unable to stop service org.schabi.newpipe.player.PlayerService@46f479d: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.setCustomActionProviders(com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector$CustomActionProvider[])' on a null object reference
	at android.app.ActivityThread.handleStopService(ActivityThread.java:5085)
	at android.app.ActivityThread.-$$Nest$mhandleStopService(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2398)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8501)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.setCustomActionProviders(com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector$CustomActionProvider[])' on a null object reference
	at org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi.updateMediaSessionActions(MediaSessionPlayerUi.java:215)
	at org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi.onMetadataChanged(MediaSessionPlayerUi.java:282)
	at org.schabi.newpipe.player.Player.lambda$updateMetadataWith$22(Player.java:1801)
	at org.schabi.newpipe.player.Player.$r8$lambda$6LL1ynLVHUrHxxol0bvWL1Rn_TU(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda47.accept(R8$$SyntheticClass:0)
	at j$.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source:19)
	at j$.util.stream.ReferencePipeline$Head.forEachOrdered(Unknown Source:10)
	at org.schabi.newpipe.player.ui.PlayerUiList.call(PlayerUiList.java:88)
	at org.schabi.newpipe.player.Player.updateMetadataWith(Player.java:1801)
	at org.schabi.newpipe.player.Player.lambda$onEvents$13(Player.java:1293)
	at org.schabi.newpipe.player.Player.$r8$lambda$5dalatdJw7zsnq99HOZvtSHTxZo(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda37.accept(R8$$SyntheticClass:0)
	at j$.util.Optional.ifPresent(Unknown Source:4)
	at org.schabi.newpipe.player.Player.lambda$onEvents$14(Player.java:1287)
	at org.schabi.newpipe.player.Player.$r8$lambda$67JZJPUrqqIwv2qPVBiXIeF-1Rs(Player.java:0)
	at org.schabi.newpipe.player.Player$$ExternalSyntheticLambda9.accept(R8$$SyntheticClass:0)
	at j$.util.Optional.ifPresent(Unknown Source:4)
	at org.schabi.newpipe.player.Player.onEvents(Player.java:1265)
	at com.google.android.exoplayer2.ExoPlayerImpl.lambda$new$0(ExoPlayerImpl.java:266)
	at com.google.android.exoplayer2.ExoPlayerImpl.$r8$lambda$FaN7Odt_OJn5xWFlmhnR2OmiNMg(ExoPlayerImpl.java:0)
	at com.google.android.exoplayer2.ExoPlayerImpl$$ExternalSyntheticLambda1.invoke(R8$$SyntheticClass:0)
	at com.google.android.exoplayer2.util.ListenerSet$ListenerHolder.release(ListenerSet.java:320)
	at com.google.android.exoplayer2.util.ListenerSet.remove(ListenerSet.java:183)
	at com.google.android.exoplayer2.ExoPlayerImpl.removeListener(ExoPlayerImpl.java:1641)
	at org.schabi.newpipe.player.Player.destroyPlayer(Player.java:573)
	at org.schabi.newpipe.player.Player.destroy(Player.java:600)
	at org.schabi.newpipe.player.PlayerService.cleanup(PlayerService.java:150)
	at org.schabi.newpipe.player.PlayerService.onDestroy(PlayerService.java:145)
	at android.app.ActivityThread.handleStopService(ActivityThread.java:5065)
	... 9 more


Feel free to hide my message if it's annoying. However, since there was the "Waiting for Author" tag for a short time, I thought I'd write my error message briefly too.

marek22k avatar May 06 '24 21:05 marek22k

See also #11066, #11061, #11065, #11068.

dolmen avatar May 12 '24 22:05 dolmen

When it will be fixed? Since few days, my newpipe is completely unusable. Anybody know, where is problem? I am using Android14.

pawlosck avatar May 24 '24 20:05 pawlosck

Exception

  • User Action: play stream
  • Request: Player error[type=ERROR_CODE_IO_BAD_HTTP_STATUS] occurred while playing https://www.youtube.com/watch?v=7urkuzv4-tg
  • Content Country: FR
  • Content Language: fr-
  • App Language: fr
  • Service: YouTube
  • Version: 0.27.0
  • OS: Linux Android 13 - 33
Crash log

com.google.android.exoplayer2.ExoPlaybackException: Source error
	at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:644)
	at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:616)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loopOnce(Looper.java:211)
	at android.os.Looper.loop(Looper.java:300)
	at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
	at org.schabi.newpipe.player.datasource.YoutubeHttpDataSource.open(YoutubeHttpDataSource.java:422)
	at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:263)
	at com.google.android.exoplayer2.upstream.TeeDataSource.open(TeeDataSource.java:52)
	at com.google.android.exoplayer2.upstream.cache.CacheDataSource.openNextSource(CacheDataSource.java:796)
	at com.google.android.exoplayer2.upstream.cache.CacheDataSource.open(CacheDataSource.java:609)
	at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
	at com.google.android.exoplayer2.source.chunk.ContainerMediaChunk.load(ContainerMediaChunk.java:124)
	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)


noone74 avatar Jul 05 '24 19:07 noone74

The same issue happened to me too, but it happened very recently (10/07/2024 at 00:00) since the 403 error now affects all video instead of only some videos before (and sometimes some videos gets 403 after passed near 1 minute)(see #11255), and on a different device, it happened on both NewPipe and Tubular fork as well, even Seal/yt-dlp constantly got connection reset by peer error

MDP43140 avatar Jul 09 '24 18:07 MDP43140

Fixed by #11261

Stypox avatar Jul 11 '24 21:07 Stypox