I noticed that Compose on Android actually implemented by AndroidComposeView
, When compose state changes and composable function starts recomposing, AndroidComposeView.invalidate()
will be called from the layout node layer (At least for now in master branch of androidx repository).
// For example: RenderNodeLayout
internal class RenderNodeLayer(
val ownerView: AndroidComposeView,
...
) : OwnedLayer {
...
override fun invalidate() {
if (!isDirty && !isDestroyed) {
ownerView.invalidate()
isDirty = true
}
}
...
}
This will invalidate the whole view. If Compose designs a larger UI, such as the entire activity via function setContent()
, even a small change to the UI will invalidate the entire content of activity. Android seems to redraw only the parts of the interface that have been changed when hardware acceleration is enabled, does it mean that Compose loses more performance? If so, how expensive the impact will be?