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

Clustering animation too slow #164

Closed
MauriFont opened this issue May 1, 2015 · 12 comments
Closed

Clustering animation too slow #164

MauriFont opened this issue May 1, 2015 · 12 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@MauriFont
Copy link

The animation is too slow. When zooming in. after all markers move to their locations the cluster circle remains there like for 2 secs until it desappears.

@meierjan
Copy link

Is it possible that the unclustering happens on all markers - not only on those that are currently displayed? My memory jumps from 12mb straight to 30mb (around 1200 markers) when zooming in. This would explain why its getting slow.

I will have a look into the code when I have some time.

@Libby713
Copy link
Contributor

As one solution you can now choose to disable the animations, which was added in 27f7a5b

@cseh17
Copy link

cseh17 commented Jul 31, 2019

Is there a solution for this issue? I have tried both with and without animation, and I still get the same result.

@stale
Copy link

stale bot commented Oct 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. label Oct 3, 2019
@jpoehnelt jpoehnelt removed the status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. label Oct 3, 2019
@danielgomezrico
Copy link

@Libby713 the issue persists even if you disable the animations, the clustering action looks ugly going from a lot of unclustered markers and they become clustered.

@daljeet33
Copy link

Would restricting the markers and therefore the clusters to only those visible within the viewport help? I am not sure if the animation currently is played out on all the cluster markers laid out on the map or only those that are within the viewport.

@jpoehnelt
Copy link
Contributor

@daljeet33 That sounds like a possible cause worth investigating.

@barbeau
Copy link
Collaborator

barbeau commented Nov 5, 2019

I agree that restricting clustering to visible viewport may help.

Another possible fix is to move to the Maps SDK for Android v3.0.0 beta (instead of Play Services):
https://developers.google.com/maps/documentation/android-sdk/v3-client-migration

The release notes say that this bug for "Poor performance adding markers: each marker takes about 25ms on the UI thread" was fixed in that release:
https://issuetracker.google.com/issues/35822423

@barbeau barbeau added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Nov 5, 2019
@barbeau
Copy link
Collaborator

barbeau commented Nov 12, 2019

Looks like @amuramoto started a transition to Android Maps SDK for Android v3 in this branch:
https://github.com/googlemaps/android-maps-utils/commits/android-sdk-v3-beta

@amuramoto Do you recall the current state of this branch, in terms of what's left to do?

@amuramoto
Copy link
Member

The standalone v3 SDK is integrated in this branch, but since the SDK is still in beta we don't want to merge with master

@barbeau
Copy link
Collaborator

barbeau commented Nov 12, 2019

@amuramoto Thanks, makes sense.

@barbeau barbeau added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jan 28, 2020
@barbeau
Copy link
Collaborator

barbeau commented Feb 14, 2020

After digging into the library a bit more, it turns out there is already an implementation of a view-based clustering algorithm - NonHierarchicalViewBasedAlgorithm.

In the demo app, this is implemented in the VisibleClusteringDemoActivity, which is the "Clustering: 20k only visible markers" button in the UI:

image

When setting up ClusterManager, you can choose to use this algorithm:

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);

        ...
        mClusterManager = new ClusterManager<>(this, getMap());
        mClusterManager.setAlgorithm(new NonHierarchicalViewBasedAlgorithm<MyItem>(
                metrics.widthPixels, metrics.heightPixels));

I modified VisibleClusteringDemoActivity to add 200,000 items and then tested performance on a Samsung Galaxy S8+ w/ Android 9 both with the default clustering algorithm, and then using NonHierarchicalViewBasedAlgorithm. There is a significant performance difference:

  1. Default - When zoomed in the default algorithm quickly gets sluggish and can no longer render the re-clustering in real-time.
  2. NonHierarchicalViewBasedAlgorithm - Continues to cluster and move markers in real-time.

After this testing, I'm fairly confident that anyone having clustering performance issues should be able to resolve them by using the NonHierarchicalViewBasedAlgorithm.

Please give that a shot and let us know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

9 participants