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

Commit d374b45

Browse files
committed
[ios] Stop using reuse queue
This commit temporarily stops using the reuse queue until we have a solution for querying point annotations on the map that is tested for the case of querying while the map is panned, rotated, and zoomed. The existing solution was not performant because: 1) There was a bug that prevented the reuse queue from being fully utilized since the updateAnnotationViews logic would pull enqueued views right off the queue when it found a nil annotationView. 2) The constant lookup / add / remove operations on the NSArray implementation of the reuse queue required a lot of CPU to keep up with. Although this commit is a regression, it is actually more performant to not use the reuse queue and to just update the center of every annotation. Once we have the ability to query for annotations that are visible in the current view port it'll make sense to bring back the reuse queue.
1 parent 20c439a commit d374b45

File tree

1 file changed

+6
-39
lines changed

1 file changed

+6
-39
lines changed

platform/ios/src/MGLMapView.mm

+6-39
Original file line numberDiff line numberDiff line change
@@ -4549,51 +4549,18 @@ - (void)updateAnnotationViews
45494549

45504550
for (auto &pair : _annotationContextsByAnnotationTag)
45514551
{
4552-
CGRect viewPort = CGRectInset(self.bounds,
4553-
-_largestAnnotationViewSize.width / 2.0 - MGLAnnotationUpdateViewportOutset.width / 2.0,
4554-
-_largestAnnotationViewSize.height / 2.0 - MGLAnnotationUpdateViewportOutset.width);
4555-
45564552
MGLAnnotationContext &annotationContext = pair.second;
4557-
MGLAnnotationView *annotationView = annotationContext.annotationView;
4558-
4553+
45594554
// Defer to the shape/polygon styling delegate methods
45604555
if ([annotationContext.annotation isKindOfClass:[MGLMultiPoint class]])
45614556
{
45624557
continue;
45634558
}
4564-
4565-
if (!annotationView)
4566-
{
4567-
MGLAnnotationView *annotationView = [self annotationViewForAnnotation:annotationContext.annotation];
4568-
if (annotationView)
4569-
{
4570-
// If the annotation view has no superview it means it was never used before so add it
4571-
if (!annotationView.superview)
4572-
{
4573-
[self.glView addSubview:annotationView];
4574-
}
4575-
4576-
annotationView.mapView = self;
4577-
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
4578-
annotationContext.annotationView = annotationView;
4579-
}
4580-
}
4581-
4582-
// if there is no annotationView at this point then we are dealing with a sprite backed annotation
4583-
if (!annotationView)
4584-
{
4585-
continue;
4586-
}
45874559

4588-
bool annotationViewIsVisible = CGRectContainsRect(viewPort, annotationView.frame);
4589-
if (!annotationViewIsVisible)
4590-
{
4591-
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
4592-
}
4593-
else
4594-
{
4595-
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
4596-
}
4560+
// TODO: add back logic to use reuse queue when there is a working solution for querying point annotation on the map
4561+
4562+
MGLAnnotationView *annotationView = annotationContext.annotationView;
4563+
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
45974564
}
45984565

45994566
[CATransaction commit];
@@ -4602,7 +4569,7 @@ - (void)updateAnnotationViews
46024569
- (void)enqueueAnnotationViewForAnnotationContext:(MGLAnnotationContext &)annotationContext
46034570
{
46044571
MGLAnnotationView *annotationView = annotationContext.annotationView;
4605-
4572+
46064573
if (!annotationView) return;
46074574

46084575
annotationView.annotation = nil;

0 commit comments

Comments
 (0)