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

PHondogo

01/30/2023, 8:10 AM
Hello! I'm using Canvas and noticed that onDraw lambda invokes more frequently than expected. Even if other composables recomposes not related with this Canvas. So when using it when drawing complex logic it cause UI hanging for seconds. What is the best practice for decreasing unnecessary redrawing?
m

myanmarking

01/30/2023, 10:00 AM
probably, those unrelated composables are at the same level, so your canvas composable recomposes as well. Without having the full code is difficult to spot the issue. But based on what you told me, other composables recompose are making the canvas to recompose as well, because other composables state is read at the same level
6 Views