googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.15k stars 139 forks source link

Huge drop in performances when setting custom clusterContent or clusterItemContent with many items #380

Closed AdrienDruesne closed 10 months ago

AdrienDruesne commented 1 year ago

Hello,

While using the Clustering in the com.google.maps.android:maps-compose-utils:2.13.0 library, if I customize the clusterContent or clusterItemContent, I have a huge drop in performances with 100+ items. Even for a simple composable as the one below, the app stutter when I move on the map, but I don't have any problem if I leave clusterContent and clusterItemContent to null.

     clusterContent = { cluster ->
             Surface(
                 Modifier.size(40.dp),
                 shape = CircleShape,
                 color = Color.Blue,
                 contentColor = Color.White,
                 border = BorderStroke(1.dp, Color.White)
             ) {
                 Box(contentAlignment = Alignment.Center) {
                     Text(
                         "%,d".format(cluster.size),
                         fontSize = 16.sp,
                         fontWeight = FontWeight.Black,
                         textAlign = TextAlign.Center
                     )
                 }
             }
         },

Thanks!

wangela commented 1 year ago

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: so we can see what is popular when we triage.

@AdrienDruesne Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

cwsiteplan commented 1 year ago

Same here, it's making the app freeze and being unusable at the moment. But even when using the default cluster+item config it's not working when adding 1000+ (clustered) markers (using latest 4.1.1)

cwsiteplan commented 1 year ago

to replicate - just increase the cluster count of the ClusterSample to e.g. 4000 lot's of GC happening according to logs and screen is freezing.

cwsiteplan commented 1 year ago

would it be possible to expand clusters only for the visible viewport? - seems like it's currently expanding on zoom level - adding lot's of individual markers on areas that are potentially not viewed at all

wangela commented 1 year ago

This seems to be a problem with the clustering utility, not specifically a Compose Utils problem. Underlying issue reported here: https://github.com/googlemaps/android-maps-utils/issues/1199

Anas304 commented 12 months ago

I am also facing this issue, is there any workaround to this?

wangela commented 10 months ago

It seems that selecting NonHierarchicalViewBasedAlgorithm would implement @cwsiteplan's suggestion to only render the items within the current viewport. Can anyone verify that this helps with a large number of items? See demonstration in #463. @AdrienDruesne @Anas304

googlemaps-bot commented 9 months ago

:tada: This issue has been resolved in version 4.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

pabloRadmas commented 9 months ago

Is there a way to set the NonHierarchicalViewBasedAlgorithm without creating a CustomClusterManager? I want to continue using this Clustering composable

Captura de pantalla 2024-01-23 a las 12 42 50

But I don't know how to set NonHierarchicalViewBasedAlgorithm in this case. At the moment I still having this problem