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

Harden std::map usage in MGLMapVIew #8637

Merged

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Apr 5, 2017

Replaced std::map::operator[] usage with std::map::at(). Backed up an assertion on iOS with a guard when -annotationTagsInRect: returns the tag of a nonexistent annotation, for consistency with macOS. Removed an unnecessary and risky subscript into _annotationContextsByAnnotationTag in -positioningRectForCalloutForAnnotationWithTag: on iOS.

/ref #8163 (comment)

Replaced std::map::operator[] usage with std::map::at(). Backed up an assertion on iOS with a guard when -annotationTagsInRect: returns the tag of a nonexistent annotation, for consistency with macOS. Removed an unnecessary and risky subscript into _annotationContextsByAnnotationTag in -positioningRectForCalloutForAnnotationWithTag: on iOS.
@1ec5 1ec5 added annotations Annotations on iOS and macOS or markers on Android iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor labels Apr 5, 2017
@1ec5 1ec5 added this to the ios-v3.5.1 milestone Apr 5, 2017
@1ec5 1ec5 self-assigned this Apr 5, 2017
@1ec5 1ec5 requested review from boundsj and fabian-guerra April 5, 2017 04:10
Copy link
Contributor

@fabian-guerra fabian-guerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@@ -3550,8 +3550,12 @@ - (MGLAnnotationTag)annotationTagAtPoint:(CGPoint)point persistingResults:(BOOL)
{
id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag];
NSAssert(annotation, @"Unknown annotation found nearby tap");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that this assertion will fail in a debug build if you perform the reproduction steps in #8163 (comment). The issue is that mbgl notion of visible annotations will always lag a bit behind the platforms' notion of the same when annotations are removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider that a bug, or is it an edge case we want to fail gracefully around from now on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bug that is an edge case 😄
But, the fix would require a callback feature for at least some of the mbgl APIs right? The platforms should not actually update their state until after core has completed updating its state (i.e. removing annotations so that queries of visible annotations won't include them)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, and we should make sure the map remains usable even in debug builds. That could be tail work, though; it seems like #8513 would have the same considerations.

Copy link
Contributor

@boundsj boundsj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@1ec5 1ec5 merged commit d39ea23 into release-ios-v3.5.0-android-v5.0.0 Apr 5, 2017
@1ec5 1ec5 deleted the 1ec5-annotation-context-at-8163 branch April 5, 2017 21:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants