Hello everyone! I'm facing some bad performance si...
# android
m
Hello everyone! I'm facing some bad performance since using compose on my Android app. I tried to reduce recompositions. Now i a have questions about this. Are modifiers costly in recompositions? On every recomposition every action on modifier like padding, background,... are reset and recalled. Some actions like onSizeChanged are called on every recomposition cause the previous size is reset. I tried to remember modifier and that reduces useless calls of onSizeChanged. Is it OK to remember modifiers?
👀 1
1
a
Building modifiers is not free but they're also not terribly expensive either; generally each modifier allocates a plain kotlin object holding its parameters or reuses a singleton instance if there are no parameters. Remembering things in the composition also isn't free; I wouldn't recommend remembering every last object you allocate or anything. I'd look to the other things you're invalidating and how frequently first
The description of onSizeChanged uses makes me wonder if you don't have a data dependency loop. This page has some good info on how to think about optimal invalidation strategies https://developer.android.com/jetpack/compose/phases
👍 2