Repository navigation
Replies: 7 comments
|
Strong skipping became the default in Kotlin 2.0.20, so I'm not sure these stability markers matter so much anymore. Have you observed some unnecessary recompositions in compostables using these types? |
|
I have experienced infinite recomposition loops even with strong skipping being on, but those were unrelated to malplibre-compose (I think it was caused by mutable collections in some library). Hasn't happened in a while, but I still have trust issues with unstable parameters. 😄 I did some more reading and it seems they don't want you to worry about stability most of the time, but stable types are still a little better at preventing unnecessary recompositions. I also asked Gemini, I think it actually gets some details about equality wrong, so take it with a grain of salt as usual: AI slop
|
|
I wonder if our types would get marked as stable (especially those data classes in spatial-k) automatically if we just include the compose compiler in the build, without introducing dependencies for non-compose users. Ideally I want to avoid asserting stability because it's not really checked at build time. But if the compiler can check and mark it for us, no harm in including that metadata in the artifact. |
|
Seems like compose compiler adds |
So, classes like But it is correct from the point of view of Compose to not deem that stable and there is nothing one can do in spatial-k to guarantee that because val coords = mutableListOf(Position(1.0,1.0), Position(1.0,2.0))
val lineString = LineString(coordinates = coords)
// and now we change lineString
coords.add(Position(1.0,3.0)) |
Short of copying, yeah, but that'd be a waste |
|
Gonna move this to discussions since it's not yet clear whether it's work we should do or not. Would be happy to move this back to issues if we can repro reasonable cases where adding these markers would prevent recompositions without lying to the compiler (like with lists) |
Uh oh!
There was an error while loading. Please reload this page.
I recently started using compose-stability-analyzer, which made me aware that all types exported by maplibre-compose and spatial-k are considered unstable by compose.
For more information on this topic, see this blog post.
Therefore, I propose that we add
@Stableor@Immutablemarkers on all applicable types. The markers are part ofandroidx.compose.runtime, but to avoid dependency bloat, we can use compose-stable-marker, a tiny module with only the markers.All reactions