TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
29.52k stars 2.95k forks source link

NewPipe crashes when re-opening a previously played video/livestream due to a NullPointerException #6652

Open ageneric opened 2 years ago

ageneric commented 2 years ago

Checklist

Purpose

This issue is intended to report the NullPointerException that occurs when player.playqueue.PlayQueueItem.getRecoveryPosition() is invoked, and the logs corresponds to this crash. In the initial report the error occurred after a different crash, which is mentioned for the sake of reproducibility (I did not open an issue for this crash as I did not keep the log).

Steps to reproduce the bug

The same error has occurred twice, however I am unable to reproduce the bug following either case. In each case the actions leading up to the crash are listed below:

Re-opening an ended live stream (0.21.5, initial report)

  1. Viewed a live stream (YouTube) using NewPipe. The live stream ended* at approximately the same time as it was opened, and the player only showed less than 5 seconds from the end of the stream.
  2. Exited video using the back button. A toast was displayed with the message "Could not play stream". I do not remember if it occurs during this step, or in the next step when NewPipe is unfocused.
  3. Unfocus the app then attempt to close it. NewPipe crashes (this is a different crash, and not covered by this issue) and brings up the bug reporting screen. Exit the bug reporting screen and close NewPipe.
  4. Re-open the app. The error now occurs.

*The live stream was set to upload as video after ending.

Re-opening an unlisted video (0.21.8)

  1. Played an unlisted YouTube video* from a link using NewPipe. The app may have been open already, so I am not certain if this was the earliest video in the stack, but it was the most recent.
  2. Unfocus the app. NewPipe displayed the video on the lock screen (not playing), so the application was open but not visible.
  3. Re-open the app. The error now occurs.

*The unlisted video still exists and was not removed.

Actual behavior

On opening NewPipe, NewPipe immediately crashes and brings up the bug reporting screen. In both cases the crash log is identical except for the Version field (but you can find the more recent log in the comment below).

Expected behavior

The video/livestream is re-opened without an error.

Logs

Error on app open following "Could not play stream" toast message and closing app. Produced on non-root Android Marshmallow. Not logged in.

Exception

java.lang.NullPointerException: Attempt to invoke virtual method 'long org.schabi.newpipe.player.playqueue.PlayQueueItem.getRecoveryPosition()' on a null object reference
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.updateProgressInfo(VideoDetailFragment.java:1644)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.handleResult(VideoDetailFragment.java:1547)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.lambda$runWorker$6(VideoDetailFragment.java:893)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.lambda$runWorker$6$VideoDetailFragment(VideoDetailFragment.java)
    at org.schabi.newpipe.fragments.detail.-$$Lambda$VideoDetailFragment$X-UcNln23jPsop2TvHe2VPTu0NQ.accept(lambda)
    at io.reactivex.rxjava3.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62)
    at io.reactivex.rxjava3.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:81)
    at io.reactivex.rxjava3.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:123)
    at android.os.Handler.handleCallback(Handler.java:746)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)


Device info

ageneric commented 2 years ago

I had the same error occur on NewPipe 0.21.8 using the same device, when restoring an unlisted YouTube video. NewPipe displayed the video on the lock screen (not playing), so the application was open but not visible. Again it crashed immediately when opened.

Note: The crash log is identical apart from the Version field.

Exception

java.lang.NullPointerException: Attempt to invoke virtual method 'long org.schabi.newpipe.player.playqueue.PlayQueueItem.getRecoveryPosition()' on a null object reference
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.updateProgressInfo(VideoDetailFragment.java:1644)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.handleResult(VideoDetailFragment.java:1547)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.lambda$runWorker$6(VideoDetailFragment.java:893)
    at org.schabi.newpipe.fragments.detail.VideoDetailFragment.lambda$runWorker$6$VideoDetailFragment(VideoDetailFragment.java)
    at org.schabi.newpipe.fragments.detail.-$$Lambda$VideoDetailFragment$X-UcNln23jPsop2TvHe2VPTu0NQ.accept(lambda)
    at io.reactivex.rxjava3.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62)
    at io.reactivex.rxjava3.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:81)
    at io.reactivex.rxjava3.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:123)
    at android.os.Handler.handleCallback(Handler.java:746)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)


litetex commented 2 years ago

Note that a similar error now starts occurring on https://github.com/TeamNewPipe/NewPipe/blob/v0.21.9/app/src/main/java/org/schabi/newpipe/player/Player.java#L674

There seems to be a shared underlying cause as the error messages are identical. In both cases Attempt to invoke virtual method 'long org.schabi.newpipe.player.playqueue.PlayQueueItem.getRecoveryPosition()' on a null object reference happens because the stream is outside a valid index: https://github.com/TeamNewPipe/NewPipe/blob/v0.21.9/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java#L169-L187

licaon-kter commented 1 year ago

Seeing this most of the time with latest version.

Kinda fixed if I FC the app and clean cache. On reopen same video just works fine.