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

Still too many recompositions #1431

Open
MV-GH opened this issue Mar 6, 2024 · 1 comment
Open

Still too many recompositions #1431

MV-GH opened this issue Mar 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MV-GH
Copy link
Collaborator

MV-GH commented Mar 6, 2024

Jerboa Version

0.0.60

Description

I did some more research into recompositions in Jerboa.

Before:

Notice how every frame the upvote/downvote/ other actions buttons recompose
But the comment counts don't? Well thats how everything supposed to be in a post

l1nbIFVqRW.mp4

I added 1 remember for upvote action

after:

The upvote doesn't recompose anymore, and only changes when its state changes (pressing upvote) pressing an action also doesn't recompose the other upvotes

4fOPBIRiM6.mp4

Exact change in postlisting.kt:

                 onUpvoteClick = remember(postView, instantScores) { {
                            instantScores = instantScores.update(VoteType.Upvote)
                            onUpvoteClick(postView)
                        } },

Conclusion:

We need to add way more remembers for every top action passed down.

@dessalines

@MV-GH MV-GH added the bug Something isn't working label Mar 6, 2024
@MV-GH
Copy link
Collaborator Author

MV-GH commented Apr 17, 2024

This is what I have been working on for the past few weeks. Still nowhere near complete but I have managed to prevent the feed from constantly recomposing. (Pinned the topbar solely for easier showcasing as its enter behaviour triggers more recompositions, which it probably shouldn't but no clue on solving that yet)

h2IYPMyFyr.mp4

It now only updates the item that has changed. But even further might be possible, as its currently fully recomposing that item and the upvote only changes one thing that is the score. So everything else that doesn't change should stay the same. But this is probably the same as the feed due to its immutable nature. olditem ~= newItem and we pass this PostView pretty much into each composable. Thus each composable its arguments are different and recomposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant