Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AdrienDruesne opened this issue Aug 17, 2023 · 9 comments · Fixed by #463
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. released type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@AdrienDruesne
Copy link

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!

@AdrienDruesne AdrienDruesne added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 17, 2023
@wangela
Copy link
Member

wangela commented Aug 17, 2023

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 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.

@kikoso kikoso added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed triage me I really want to be triaged. labels Sep 29, 2023
@cwsiteplan
Copy link

cwsiteplan commented Oct 30, 2023

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
Copy link

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
Copy link

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
Copy link
Member

wangela commented Oct 31, 2023

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

@Anas304
Copy link

Anas304 commented Nov 2, 2023

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

@wangela wangela added priority: p2 Moderately-important priority. Fix may not be included in next release. status: blocked Resolving the issue is dependent on other work. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. status: blocked Resolving the issue is dependent on other work. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 14, 2023
@wangela
Copy link
Member

wangela commented Dec 15, 2023

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
Copy link
Contributor

🎉 This issue has been resolved in version 4.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@pabloRadmas
Copy link

pabloRadmas commented Jan 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. released type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
7 participants