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

Flickering pins on annotation updates #23

Closed
mrylmz opened this issue Sep 18, 2017 · 11 comments
Closed

Flickering pins on annotation updates #23

mrylmz opened this issue Sep 18, 2017 · 11 comments

Comments

@mrylmz
Copy link

mrylmz commented Sep 18, 2017

ClusterKit is causing a flickering issue on custom annotation views using MapKit.

I have tried solving this issue by using: - addAnnotations(...) and - removeAnnotations(...),
but that doesn't seam to solve the problem.

I'm calling - updateClustersIfNeeded in -mapView(_:, regionDidChangeAnimated:) as described in the documentation.

Tested with:

  • iOS Version 11.0 GM Seed
@maxep
Copy link
Contributor

maxep commented Sep 18, 2017

Thanks for the report @roccx , I've also noticed that flickering on iOS11
I havent found a solution yet.

@jacogasp
Copy link

I'm using custom annotations views with an animation during the update and running iOS11.
Everything works perfectly but the animation occurs also for clusters/annotations that don't change during the update.
For me it seems like that during mapView(_:, regionDidChangeAnimated:) all the annotations are rebuilt even the ones that should not be updated. Could the flickering related to this?

@mrylmz
Copy link
Author

mrylmz commented Sep 20, 2017

I think the issue is that every annotation is replaced by new ones as @jacogasp says. Isn't there a way to filter annotations by -isEqual(_:) or -hash?

@lennartstein
Copy link

I did some debugging and I can say, that the flickering just happens when zooming not when moving the map to west/east/north/south. mapView(_:, regionDidChangeAnimated:) just rebuilt the annotations when zooming and moving the map. When moving without zooming it doesn't happen. Maybe there is some issue with the zooming?

@mrylmz
Copy link
Author

mrylmz commented Sep 30, 2017

It seems like MKMapView is delaying the rendering process of new annotations in some way. Yes I think the annotations are all rebuild because the algorithm instance is getting replaced on zoom.

I think a solution for that problem would be to manage the annotations in a more smarter way or just delay the removal of the old annotations by 2 or 3 frames.

@jacogasp
Copy link

jacogasp commented Oct 2, 2017

@frgmt the refresh occurs to me also panning the map without zooming.

@maxep
Copy link
Contributor

maxep commented Oct 2, 2017

The issue appears everytime the clusters are updated, on zoom or significant pan. As @roccx suggested, adding an annotation to MKMapView seems to be delayed. The idea would be to update the clusters (replace, expand, collapse) more efficiely. The update is made in the private method updateMapRect:animated:, the implementation should be rethink.

@kkvinokk
Copy link

@maxep is anyone working on the solution for this issue? Please let us know when this is fixed.

In the time being is there any good alternative to fix this issue?

@thibauddavid
Copy link

I had the similar problem, and after some research, it happens that ClusterKit reloads each annotations on each pan, rotation etc.
I began to debug the lib, but didn't found any problem in the algorithm which could cause this bug.
As some said above, the underlying problem is that annotation adding are delayed in MKMapView compared to annotation removal (even if they are added before other get removed.)

In my case, the issue was mainly visible because I have several type of annotationViews, on which I update the image depending on type of annotation to display.
As annotationViews got reused, same pin could be reconfigured from a previous recycled pin (with a different image), causing a glitch on each reload.

My workaround consists in having 1 reuseIdentifier per annotation type (including CKCluster), thus configuring my annotationViews only after instantiating them.
As a result, my annotationViews are 100% stable, without any glitch.

Hope that helps !

@maxep
Copy link
Contributor

maxep commented Oct 18, 2017

I've released a new version : 0.3.0 including breaking changes answering this issue.
The clusters' updates and animations are now more efficient and as @thibauddavid described, making a good use of the reusable annotation view is a good practice.

Please check the CHANGELOG

@maxep maxep closed this as completed Oct 18, 2017
@thibauddavid
Copy link

Just read new algorithm, seems much more efficient 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants