I recently tried to do an analysis of `composable`...
# compose
s
I recently tried to do an analysis of
composable
based on chris’s article, and then I found out that painter is unstable, resulting in some
composable
being non-skippable, Why can’t add @Immutable or @Stable to painter and How to change composable with a painter parameter to skippable?
Copy code
restartable scheme("[androidx.compose.ui.UiComposable]") fun NormalImage(
  unstable painter: Painter
  stable contentDescription: String?
  stable modifier: Modifier? = @static Companion
  stable tint: Color = @dynamic LocalContentColor.current
)
m
@Stable data class(val painter: Painter). Or just use remember{ Painter }
but i wouldn’t care about that. It’s fine
t
I wonder why painter is not immutable
z
Painters are definitely not required to be immutable, but I would expect them to be stable. 🤔
👍 2
Ok i’ve asked around and it seems the main answer is simply backwards compatibility. Painter was already pretty established by the time
@Stable
came around, so it was too late to change its contract by then.
As always, recomposition isn’t inherently a bad thing. Profile profile profile
If recomposition of this function seems to be a major cause of performance issues, then worry about how to pass a painter around without recomposing.
👍 2