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

Instead of crashing, or showing an error, can Newpipe just... not scroll? #3368

Closed
opusforlife2 opened this issue Apr 5, 2020 · 4 comments · Fixed by #7659
Closed

Instead of crashing, or showing an error, can Newpipe just... not scroll? #3368

opusforlife2 opened this issue Apr 5, 2020 · 4 comments · Fixed by #7659
Labels
bug Issue is related to a bug

Comments

@opusforlife2
Copy link
Collaborator

opusforlife2 commented Apr 5, 2020

Version

  • 0.21.9 (earlier 0.19.1)

Steps to reproduce the bug

  1. Search something.
  2. Turn off internet.
  3. Scroll down the list.

Expected behavior

Since Newpipe can't load new items in the list without internet, it should just not scroll after the last already loaded one. You could mention the network error and show the retry button in the space below the last list item.

Actual behaviour

Screen clears and shows Network Error with a Retry button.

In rare cases like I just got, crash. UI error. It seems to involve the AndroidX RecyclerView.

Interestingly, with this error page, tapping back takes you to the home screen, but you can open Newpipe from its launcher and use it without any error. If you tap back from there, though, you're taken to the error page again. It's in the backstack or something.

If you turn internet back on and then open Newpipe, it removes the error page from the backstack.

Logs

Exception

  • User Action: ui error
  • Request: App crash, UI failure
  • Content Language: en_IN
  • Service: none
  • Version: 0.19.1
  • OS: Linux Android 9 - 28
Crash log

java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder{7611833 position=20 id=-1, oldPos=-1, pLpos:-1 not recyclable(1)} androidx.recyclerview.widget.RecyclerView{42907f0 VFED.V... ......ID 0,0-1080,1728 #7f090150 app:id/items_list}, adapter:org.schabi.newpipe.info_list.InfoListAdapter@983b169, layout:androidx.recyclerview.widget.LinearLayoutManager@d56b7ee, context:org.schabi.newpipe.MainActivity@88466a3
	at androidx.recyclerview.widget.RecyclerView$5.attachViewToParent(RecyclerView.java:915)
	at androidx.recyclerview.widget.ChildHelper.attachViewToParent(ChildHelper.java:239)
	at androidx.recyclerview.widget.RecyclerView.addAnimatingView(RecyclerView.java:1431)
	at androidx.recyclerview.widget.RecyclerView.animateDisappearance(RecyclerView.java:4161)
	at androidx.recyclerview.widget.RecyclerView$4.processDisappeared(RecyclerView.java:612)
	at androidx.recyclerview.widget.ViewInfoStore.process(ViewInfoStore.java:240)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3994)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3652)
	at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1888)
	at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5044)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
	at android.view.Choreographer.doCallbacks(Choreographer.java:761)
	at android.view.Choreographer.doFrame(Choreographer.java:693)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6718)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


@opusforlife2 opusforlife2 added the bug Issue is related to a bug label Apr 5, 2020
@opusforlife2
Copy link
Collaborator Author

opusforlife2 commented Aug 15, 2020

@Stypox This is very similar to #3923 and #4304. Probably has a similar solution.

@opusforlife2
Copy link
Collaborator Author

opusforlife2 commented Sep 18, 2021

Slightly different crash on 0.21.9 (caught by Scoop, not Newpipe):

FATAL EXCEPTION: main
Process: org.schabi.newpipe, PID: 18498
java.lang.IllegalArgumentException: Called attach on a child which is not detached: HFHolder{76bce37 position=19 id=-1, oldPos=-1, pLpos:-1} androidx.recyclerview.widget.RecyclerView{745bfa4 VFED.V... ......ID 0,0-1080,1728 #7f0a01c0 app:id/items_list}, adapter:org.schabi.newpipe.info_list.InfoListAdapter@5eec10d, layout:org.schabi.newpipe.views.SuperScrollLayoutManager@28858c2, context:org.schabi.newpipe.MainActivity@b85af6e
	at androidx.recyclerview.widget.RecyclerView$5.attachViewToParent(RecyclerView.java:920)
	at androidx.recyclerview.widget.ChildHelper.attachViewToParent(ChildHelper.java:239)
	at androidx.recyclerview.widget.RecyclerView.addAnimatingView(RecyclerView.java:1436)
	at androidx.recyclerview.widget.RecyclerView.animateDisappearance(RecyclerView.java:4371)
	at androidx.recyclerview.widget.RecyclerView$4.processDisappeared(RecyclerView.java:615)
	at androidx.recyclerview.widget.ViewInfoStore.process(ViewInfoStore.java:242)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4204)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3862)
	at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1897)
	at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5260)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:967)
	at android.view.Choreographer.doCallbacks(Choreographer.java:791)
	at android.view.Choreographer.doFrame(Choreographer.java:722)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7356)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)

@litetex
Copy link
Member

litetex commented Jan 14, 2022

I think the problem might be related to

case HEADER_TYPE:
return new HFHolder(header);
case FOOTER_TYPE:
return new HFHolder(footer);

According to https://stackoverflow.com/a/42865352 and https://speakerdeck.com/yigit/pro-recyclerview?slide=94 (found in a similar google issue) every viewholder has to create/inflate it's own view.
In the above code the views(header and footer) are likely reused and the crash happens.

Related to #4475

Update:

Okay, this problem and #4475 are definitely caused by the above code.
How did I found this out?

Update2:
The problem must be at least 5 years present → 8f73473#diff-d075c1aaf95acf093a7feaa093198bfbc9c4d5b479e2b57effdaf7a9e74448d9R133

litetex added a commit to litetex/NewPipe that referenced this issue Jan 16, 2022
* Always recreate the footer so that it's not possible to attach the same instance twice
* Removed support for creating a custom footer as it's never used
* Supply the header with an supplier
  * This might not fix the problem completely as we currently can only create the header once inside Channel, Playlist and RelatedItems-Fragment - allowing creation of multiple headers might be done in the future if the issues still arise
* Other minor fixes
litetex added a commit to litetex/NewPipe that referenced this issue Jan 16, 2022
* Always recreate the footer so that it's not possible to attach the same instance twice
* Removed support for creating a custom footer as it's never used
* Supply the header with an supplier
  * This might not fix the problem completely as we currently can only create the header once inside Channel, Playlist and RelatedItems-Fragment - allowing creation of multiple headers might be done in the future if the issues still arise
* Other minor fixes
@Stypox
Copy link
Member

Stypox commented Jan 24, 2022

@litetex congratulations for that finding! It's a really nasty bug and I couldn't understand the issue even after debugging on multiple occasions... :-D

litetex added a commit to litetex/NewPipe that referenced this issue Jan 24, 2022
* Always recreate the footer so that it's not possible to attach the same instance twice
* Removed support for creating a custom footer as it's never used
* Supply the header with an supplier
  * This might not fix the problem completely as we currently can only create the header once inside Channel, Playlist and RelatedItems-Fragment - allowing creation of multiple headers might be done in the future if the issues still arise
* Other minor fixes
litetex added a commit to litetex/NewPipe that referenced this issue Feb 17, 2022
* Always recreate the footer so that it's not possible to attach the same instance twice
* Removed support for creating a custom footer as it's never used
* Supply the header with an supplier
  * This might not fix the problem completely as we currently can only create the header once inside Channel, Playlist and RelatedItems-Fragment - allowing creation of multiple headers might be done in the future if the issues still arise
* Other minor fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants