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

Load enough initial items and fix crash in lists (BaseListFragment and descendants) #7659

Merged
merged 10 commits into from
Feb 19, 2022

Conversation

litetex
Copy link
Member

@litetex litetex commented Jan 15, 2022

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Before/After Screenshots/Screen Record

NP7659Demo1.gif.mp4

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Tips for testing:

  • The changes can be at best tested with a tablet and Grid-mode enabled

Due diligence

@litetex litetex marked this pull request as draft January 15, 2022 16:13
@litetex

This comment has been minimized.

@triallax triallax requested review from triallax and removed request for triallax January 16, 2022 05:41
@triallax triallax added bug Issue is related to a bug GUI Issue is related to the graphical user interface labels Jan 16, 2022
litetex added a commit to litetex/NewPipe that referenced this pull request Jan 16, 2022
The previous/reverted behavior caused unwanted data transmission:
* Removed loading via handleResults/loadMoreItems-callback because the RecyclerView is apparently not immediately updated in the UI when the data is set which causes one load of data to much.
@litetex
Copy link
Member Author

litetex commented Jan 16, 2022

So after extensive testing, finding out about unexpected behaviors and so on, I decided to use the original idea/behavior from #7638 and improved it, because loading via handleResults/loadMoreItems-callback causes the RecyclerView apparently to not be immediately updated in the UI when the data is set - which causes one load of data to much.

@litetex litetex changed the title Load enough initial data into BaseListFragment Load enough initial items (into BaseListFragment and descendants) Jan 16, 2022
@opusforlife2

This comment has been minimized.

@litetex litetex force-pushed the load-enough-initial-data branch from 0c586c9 to 3aab187 Compare January 16, 2022 18:16
@litetex litetex marked this pull request as ready for review January 16, 2022 18:45
@litetex litetex force-pushed the load-enough-initial-data branch from 24e9485 to f4d02c1 Compare January 16, 2022 18:52
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for this much needed fix. :-)
I still haven't tested

@litetex litetex force-pushed the load-enough-initial-data branch from fb2792e to cb78433 Compare January 24, 2022 19:57
litetex added a commit to litetex/NewPipe that referenced this pull request Jan 27, 2022
@AudricV AudricV requested a review from Stypox February 8, 2022 08:47
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, thank you!

I tested on my phone (FP3 API 29) and everything went well. I then tested on an emulated tablet API 31 and found a small issue:

  • create a tablet emulator with a big enough screen (e.g. Pixel C in Android Studio)
  • start & rotate the device to portrait (with auto rotate on, so that it actually rotates)
  • open Souncloud's "New and hot": the trending video list will be shown with items in the "large/long" variant
  • rotate the device to landscape: now the items will be shown in the "mini" variant, so they use up less space and the loading footer appears. But nothing ever starts loading and there is no way to start loading even if rotating back to portrait.

Ignore all of the above, the issue is simpler: just open a trending or channel fragment and rotate the device. The list will stop loading new items and there is no way to trigger items loading, even when scrolling down to the bottom or even when rotating back to the original rotation.
With the search fragment it's even worse: the loading indicator doesn't even show up after rotating, even though the search results aren't finished.
The comments fragment seems to work correctly though even after rotation.

Other than this I couldn't find other issues.

* Removed unused code
* Cleaned it up
* Made code more readable
because if you modify something in the code the suppressions-file no longer matches
Removed - partial - stupid code.
* 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
The previous/reverted behavior caused unwanted data transmission:
* Removed loading via handleResults/loadMoreItems-callback because the RecyclerView is apparently not immediately updated in the UI when the data is set which causes one load of data to much.
@litetex litetex force-pushed the load-enough-initial-data branch from 1df64c1 to 2acaefd Compare February 17, 2022 20:00
@litetex
Copy link
Member Author

litetex commented Feb 17, 2022

@Stypox
Should be fixed now.
Now there is always a scroll listener (like before the PR).

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm it's fixed. Ready in my opinion! :-D

I found other two small issues that are not caused by this PR and should not be fixed here:

  • when scrolling down fast and there are more items, sometimes the view suddenly stops scrolling right above the loading footer, instead of scrolling down to the bottom of the footer. Items start loading anyway, but since the scroll stopped before the loading indicator could become visible, to the user it may seem like there are no more items.
  • when pressing Android's square button (to view recent apps) and rotating the device at the same time, and then going back to the app, the (search) fragment starts reloading the list from the beginning. No such problem happens when the app just resumes from recents (e.g. because its state was saved to disk after a RAM shortage).

@Stypox Stypox merged commit af80d96 into TeamNewPipe:dev Feb 19, 2022
@Stypox Stypox changed the title Load enough initial items (into BaseListFragment and descendants) Load enough initial items and fix crash in lists (BaseListFragment and descendants) Feb 19, 2022
@TobiGr
Copy link
Contributor

TobiGr commented Feb 19, 2022

I found other two small issues that are not caused by this PR and should not be fixed here:

@Stypox Can you check whether there are open issues for this already and open new ones if necessary?

@Stypox
Copy link
Member

Stypox commented Feb 19, 2022

@TobiGr done: #7908 #7909

@litetex litetex deleted the load-enough-initial-data branch February 20, 2022 13:29
@Stypox Stypox mentioned this pull request Feb 23, 2022
3 tasks
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 GUI Issue is related to the graphical user interface
Projects
None yet
6 participants