cloudstream
cloudstream copied to clipboard
Separate loading view from homepage
Thanks for your project, it helped me a lot.
I have a device with poor performance, when cloudstream is running on it, some operations cause stuttering, so I want to optimize its performance.
I first found that the home page has a lot of unnecessary loading status views, and we can remove them completely when the loading is over. I added a framelayout as the fragment's container, and loaded the loading state as a fragment into the container.
In this way we can separate the loading part from the home page, which will make the code more maintainable.
Intresting
Does it actually improve performance for you?
I'm still working on other parts. This is just a small part. I did some simple measurements and below are my data.
Before the change, it takes about 350ms to load the layout (inflate view) on the homepage (on my xiaomi mi6 sagit), after separation, it takes 300ms to inflate the view, which is still time-consuming but helpful.
In the next step, I plan to use constraint layout to reduce layout nesting, and use View+Drawable to replace the placeholder CardView, which should also help.
Ok, sounds nice. I was planning on doing a tv homepage UI rework, but I will hold off on that while you do this
Upon investigation it looks like the main culprit of slow load times is the main recyclerview not recycling as it's in a nested scroll view. This will get fixed soon.
You can set the reuse pool of these recyclerviews to be the same. Going a step further, you can even use recyclerview nested recyclerview to implement the main page (of course, you also need to set their reuse pool to the same, which will make some Views enter the recycling stack).
Referer: RecyclerView#setRecycledViewPool
But let's still pick up some cigarette butts and do small optimizations like splitting the home page state, which I think are good for maintaining the code and are not as heavy as the above mentioned optimizations and can be done easily. This PR is complete, you can merge it directly, of course, if you have a better way, you can also modify it after closing it. This is your project, feel free to do it.
Don't get me wrong, this pr will get merged and I'm very thankful for it, I'll do a proper check tomorrow 🙏 I'm just informing you to get opinions and prevent double work
And I mean the vertical recyclerview, it's currently inside a nested scroll view to allow the top stuff to be displayed. If you got any ideas how to implement that without dragging the header logic inside the recyclerview itself it'd be a godsend 🙏
Rendering 18 rows at once is extremely heavy on the UI thread 💀
I think the current approach is acceptable if you don't want nesting to optimize performance. ViewPager2 itself is a RecyclerView, sharing the reuse pool will help, and RecyclerView#setHasFixedSize will also help.
Ill try to fix the conflicts soon
closing as stale and outdated with the new binding system