Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Switching styles turns annotations invisible #1488

Closed
1ec5 opened this issue May 9, 2015 · 25 comments · Fixed by #2420
Closed

Switching styles turns annotations invisible #1488

1ec5 opened this issue May 9, 2015 · 25 comments · Fixed by #2420
Labels
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented May 9, 2015

Changing the style causes any annotations in view to become invisible. Any popover remains visible, and invisible annotations continue to respond to taps.

pindrop

@1ec5
Copy link
Contributor Author

1ec5 commented May 9, 2015

Zooming in and out causes the annotations to appear and disappear – with the old style's sprites.

@bsudekum, this is likely the issue you were seeing with your React Native project.

@incanus
Copy link
Contributor

incanus commented May 9, 2015

This will go away when we lift annotation imagery out of the sprite sheet. This might be an acceptable part of the b1 stopgap.

@incanus
Copy link
Contributor

incanus commented Jun 15, 2015

I'm ok with this being a stopgap again in b2, meaning you need to set style and leave it before adding/managing annotations for now. b3's focus thus far is better annotations.

@ejdslayer
Copy link

Hi, so is there a stable beta version available that will address this issue for now? I don't mind re-adding the annotations etc, I just need this ready for a project due to launch in 3 weeks. Thanks

@kristfal
Copy link

Ref #2326, is there any known workarounds for this?

This issue now persists across app launches in ios-v2.1.2 (even when closing the app from the task manager), making annotations unusable in any context where a style may be swapped.

@incanus Any ideas for how to bridge this bug? We've tried to looked into the c++ core, but can't really find the root problem.

@robipresotto
Copy link

@incanus map caches the icon annotation anyway if we set it after or before the map style. Any suggestion?

@maciekish
Copy link
Contributor

cc @Zakay

@maciekish
Copy link
Contributor

FWIW 3ec610c did not fix the issue.

@Zakay
Copy link

Zakay commented Oct 1, 2015

+1 I'm really hoping this gets fixed asap, we are so close to launch our app with a reach of 1million users, and this is a major blocking issue.

@ljbade
Copy link
Contributor

ljbade commented Oct 2, 2015

@jfirebaugh I vote associating it with annotation object, makes more sense. Like setSpriteForAnnotation

@incanus incanus added the P0 label Nov 4, 2015
@incanus
Copy link
Contributor

incanus commented Nov 13, 2015

@jfirebaugh Ok to pass this to @adam-mapbox? He's gonna dig a bit on possible solutions, and I think what you did in annotations recently lays the foundation / this doesn't intersect too much with the style API work?

@jfirebaugh
Copy link
Contributor

👍

To expand on my previous comment: the issue is that sprite icons are owned by Style (via SpriteStore), so when you change the style, all annotation sprites added via Map::setSprite are gone.

Associating the icon directly with the annotation object seems like a decent solution (should be done by modifying PointAnnotation class, not by adding setSpriteForAnnotation though). However, this will require that SpriteStore deduplicates sprites based on their contents, so as not to blow up the store with multiple copies of the same sprite, when used by multiple annotations.

@incanus incanus assigned adam-mapbox and unassigned jfirebaugh Nov 13, 2015
@ljbade
Copy link
Contributor

ljbade commented Nov 15, 2015

@jfirebaugh While someone is in here, fixing removeSprite will also be useful for when annotations are deleted. Currently if you add and delete enough unique sprite annotations, the sprite store will fill up.

Ref #2560

adam-mapbox added a commit that referenced this issue Nov 17, 2015
@adam-mapbox
Copy link
Contributor

#3049

@mb12
Copy link

mb12 commented Nov 17, 2015

1.) SpriteAtlas is expensive (memory wise). Is it possible to delay creation of annotationSpriteAtlas until it is actually needed (first time a marker point is added to the map)?

2.) Also is it possible to expose and test a remove method in the SpriteAtlas/SpriteStore that can used to free up the memory allocated for a marker image when its no longer needed?

@adam-mapbox
Copy link
Contributor

#1 is complete

For #2: What is the right way to expose a method by which sprites can be removed? Should there be a sister method to -MGLAnnotationImage annotationImageWithImage:reuseIdentifier: ? Maybe some kind of deleteAnnotationImageWithReuseIdentifier:? There already is a way to remove sprites from a sprite store, I just have to expose it somehow.

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 17, 2015

What is the right way to expose a method by which sprites can be removed?

-[MGLMapView didReceiveMemoryWarning] would be a good place to perform this kind of work.

@incanus
Copy link
Contributor

incanus commented Nov 17, 2015

-[MGLMapView didReceiveMemoryWarning] would be a good place to perform this kind of work.

Not sure about that; if memory gets low, we could legitimately jettison cached tiles and the like, but getting rid of sprites would cause the map to not render annotations?

@incanus
Copy link
Contributor

incanus commented Nov 17, 2015

Also, let's keep the discussion about @adam-mapbox's code in #3049 over in that ticket, instead of here in the problem side of things.

@adam-mapbox
Copy link
Contributor

I think @1ec5 's idea was that we only jettison those that aren't being used anymore? But that's actually pretty tough to do if we're not informed of them. It might also break the contract of the API.

@incanus
Copy link
Contributor

incanus commented Dec 1, 2015

🎉

This should land in iOS 3.1.0 (next feature release) so no need to cherry-pick the fix anywhere just yet, as that will be based off of master.

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

Successfully merging a pull request may close this issue.