Skip to content

Optimize recompositions on focus change#1138

Merged
damontecres merged 7 commits intodamontecres:mainfrom
rozPierog:leon/home-screen-optimization
Mar 31, 2026
Merged

Optimize recompositions on focus change#1138
damontecres merged 7 commits intodamontecres:mainfrom
rozPierog:leon/home-screen-optimization

Conversation

@rozPierog
Copy link
Copy Markdown
Contributor

@rozPierog rozPierog commented Mar 24, 2026

Description

I've look at the app using Layout inspector to see if there are any recompositions that shouldn't be happening while navigating normally in the app. I've noticed two issues

  1. Every BannerCard was being recomposed on every cursor move, which added a lot of overhead to home screen navigation
  2. Tab row in the Series View was being recomposed while navigating across episodes in given season.

Related issues

Performance on the home screen is lacking, especially on low end devices, while this isn't a full fix, it will improve the navigation, as the app will be making significantly less work.

Probably will fix #1043

Testing

Using Layout Inspector built-in recomposition counter and highlights it's easy to see components which recompose while they shouldn't. I've tested it on a 4K TV emulator on my M1 Macbook Pro

Screenshots

main:
image

my branch:
image

same navigation, on the same content. (down, right x4

AI or LLM usage

Gemini built in to Android Studio helped me identify non-stable parts of the code. It also helped me understand and implement fixes in the HomePage code.
I've took the time to check manually that it didn't alter any behavior, and verified the fixes using Layout Inspector and recomposition counter

@rozPierog
Copy link
Copy Markdown
Contributor Author

Hi @damontecres I also see a way to improve recompositions of the background on the homepage. Let me know if you are interested in the performance work being submitted, I don't want to step on your toes if you have some work planned in that regard!

@damontecres
Copy link
Copy Markdown
Owner

Let me know if you are interested in the performance work being submitted, I don't want to step on your toes if you have some work planned in that regard!

Hi @rozPierog, thanks for the contribution! Optimizations & performance improvements are always welcome!

My only ask would be to try to keep individual optimization PRs relatively small & focused. That way it is 1) easier to review and 2) easier to measure actual improvements. At a glance, this PR looks very focused and I appreciate that you included the recomposition results from the layout inspector.

I'm looking forward to reviewing and testing this!

@damontecres damontecres added the enhancement New feature or request label Mar 25, 2026
Copy link
Copy Markdown
Owner

@damontecres damontecres left a comment

Choose a reason for hiding this comment

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

Thanks again for the contribution! There's definitely some performance improvements here.

I left a few suggestions & questions!

Comment thread app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt Outdated
Comment thread app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt Outdated
Comment thread app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt Outdated
Comment thread app/src/main/java/com/github/damontecres/wholphin/ui/cards/BannerCard.kt Outdated
Comment thread app/src/main/java/com/github/damontecres/wholphin/ui/main/HomePage.kt Outdated
@rozPierog
Copy link
Copy Markdown
Contributor Author

@damontecres thanks for the review. I've applied the suggestions, and cleaned up the changes a bit based on your comments

@rozPierog
Copy link
Copy Markdown
Contributor Author

@damontecres congrats on a big 0.6 release! I know that it's often hard to find the time, but I would appreciate your re-review after changes.
I have more optimization in the pipeline (see #1152 ) but I think I'll split it up into bunch of small PRs to make your life easier, but before I do that I would like to make sure that my changes are correct and you are happy with them so I'm waiting for this PR to get merged.

Copy link
Copy Markdown
Owner

@damontecres damontecres left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@damontecres damontecres merged commit 762a5e6 into damontecres:main Mar 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with titles and posters glitching/jumping on home screen

2 participants