android-maps-compose
android-maps-compose copied to clipboard
Performance penalty throughout API from LatLng usages
android-maps-compose 2.2.1 compose 1.2.0-rc01
The android-maps-compose API imposes a performance penalty throughout by leveraging the Maps SDK LatLng type, which the compiler is currently unable to infer as stable. (Observed via compose compiler metrics: https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md)
I see 2 potential solutions:
- Replace LatLng with an equivalent stable type throughout maps-compose API.
- Work with compose compiler team to treat LatLng as stable.
I'd consider the second solution preferable.
Code example
@Composable
fun MyComposable(latLng: LatLng) {}
In this example the Compose compiler deems latLng unstable, rendering the composable function non-skippable.
The compiler is not able to infer the stability on LatLng as it is an external module. The solutions you propose are indeed the ways to resolve this and I agree that (2) is the right approach. For (1), I'm hesitant introducing a wrapper class as this issue should be addressed at the compiler level. Not much we can do on the maps-compose side to address this, but I will definitely raise this to the compiler team. Thanks for reporting!
Hi! We ran into this too. Do we have any update on this issue?
Quick update on the compiler side of things:
Compose 1.5.4 compiler released an experimental feature called strong skipping. This will allow composables with unstable parameters to be skipped which should improve performance. Since it is still experimental, I do recommend testing this first to see if you get any runtime performance gains.
How about "Allow configuring stability via a config file?", also released in 1.5.4. Sounds more ready to use, wouldn't it address this issue as well? https://android-review.googlesource.com/c/platform/frameworks/support/+/2668595
Yes, that should address the issue as well (a combination of the two should be tested). It'd be great if maps compose can ship with the necessary stability config file.
:tada: This issue has been resolved in version 4.3.4 :tada:
The release is available on:
v4.3.4- GitHub release
Your semantic-release bot :package::rocket: