Skip to content

Clustering: adding around ~500 POIs makes the map lag heavily on zooming #876

@juschmitt

Description

@juschmitt

Environment details

  1. Samunsg Galaxy A33 - Android 16 and other low-end devices. Though this was also visible on a Pixel 8, albeit not as bad as on lower-end devices.
  2. latest library version

Steps to reproduce

  1. In the sample app here change the number of clusters generated from 10 to 500
  2. run the sample app
  3. switch to CustomUiClustering (though its also visible with the default clustering)
  4. zoom in and out of the area with clusters

there is a visible lag, happening as soon as the POIs are clustered/unclustered. The profiler shows janky frames during that time that take up to 500ms, sometimes even more.
During that time the app is unresponsive.

I have been first experiencing this in my app where I have around 500 POIs on a rather small-ish area.
Using the NonHierarchicalViewBasedAlgorithm helps a bit, but does not get rid of all lag.

Trying the same steps with the xml version of google maps and clustering, there is no such lag happening.

I have been debugging this and found that the ComposeUiClusterRenderer does a lot of extra work that leads to re-rendering/repeated bitmap generation of unchanged POIs and re-creation of InvalidatingComposeView.

I invested some time into this and have a branch on my fork which works a lot smoother when combined with the NonHierarchicalViewBasedAlgorithm. At least the DefaultClustering is IMO on par with the xml version of google maps in terms of performance.

I'd be happy to open a PR and discuss how we can improve this further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions