https://kotlinlang.org logo
#compose
Title
# compose
t

Trey

12/06/2023, 5:44 PM
I'm trying to diagnose why some composables are getting recomposed more often that I expect. Is there an easy way to diagnose what triggers the recompose using a tool like layout inspector?
f

Filip Wiesner

12/06/2023, 6:11 PM
Never tried it but you can check out Rebugger from @theapache64
❤️ 1
j

Joel Denke

12/06/2023, 6:21 PM
See https://developer.android.com/jetpack/compose/tooling/layout-inspector#recomposition-counts There is more tools but a good start :) Also if using Android Studio Hedgehog should see recomposition state values in real time as well :)
t

theapache64

12/06/2023, 7:44 PM
+1 for Rebugger 😛
😀 2
t

Trey

12/06/2023, 7:45 PM
Thanks for the suggestion. Unfortunately this is Compose multiplatform and rebugger isn't a drop in for common code.
I moved my code to use the expect/actual pattern and I used Rebugger. Does having more than one thing change cause the recomposition to change the number of times as the things that changed? I posted a code snippet with my log output in the main channel. Rebugger confirmed that two things changing caused two recompositions of the function. I expected only one recomposition that changed both parameters at once.
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 3:42 PM
Your expectation is correct. Something else must be going on. Hard to say without seeing any code
👍 1
t

Trey

12/07/2023, 3:47 PM
I figured it out. I was updating a remembered variable that changed based on the flow. That was causing the extra recomposition. Thanks for all the help!
👍 1
👍🏻 1
2 Views