Skip to content

Commit

Permalink
Annotation view recycling re-enabled (maplibre#2454)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcristici authored May 30, 2024
1 parent 7f366a7 commit e082e05
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions platform/ios/src/MLNMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6976,14 +6976,18 @@ - (void)updateAnnotationViews

if (annotationView)
{
annotationView.center = MLNPointRounded([self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self]);
CLLocationCoordinate2D coordinate = annotation.coordinate;

// Every so often (1 out of 1000 frames?) the mbgl query mechanism fails. This logic spot checks the
// offscreenAnnotations values -- if they are actually still on screen then the view center is
// moved and the enqueue operation is avoided. This allows us to keep the performance benefit of
// using the mbgl query result. It also forces views that have just gone offscreen to be cleared
// fully from view.
if (!MLNCoordinateInCoordinateBounds(annotation.coordinate, coordinateBounds))
if (MLNCoordinateInCoordinateBounds(coordinate, coordinateBounds))
{
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
}
else
{
if (annotationView.layer.animationKeys.count > 0) {
continue;
Expand All @@ -6993,12 +6997,8 @@ - (void)updateAnnotationViews
CGPoint adjustedCenter = annotationView.center;
adjustedCenter.x = -CGRectGetWidth(self.frame) * 10.0;
annotationView.center = adjustedCenter;

// Disable the offscreen annotation view recycling on Metal because of issue https://github.com/maplibre/maplibre-native/issues/2117
// TLDR: Metal view rendering stutter / freeze
#if !MLN_RENDER_BACKEND_METAL
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
#endif

[self enqueueAnnotationViewForAnnotationContext:annotationContext];
}
}
}
Expand Down

0 comments on commit e082e05

Please sign in to comment.