Annotation view recycling re-enabled (#2454)

This commit is contained in:
Alex Cristici
2024-05-31 00:31:43 +03:00
committed by GitHub
parent 7f366a7583
commit e082e0566a

View File

@@ -6976,14 +6976,18 @@ static void *windowScreenContext = &windowScreenContext;
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;
@@ -6993,12 +6997,8 @@ static void *windowScreenContext = &windowScreenContext;
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];
}
}
}