Skip to content

Commit

Permalink
Workaround for issue #2117 (#2148)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankarschti authored Mar 7, 2024
1 parent 1ba9a47 commit 9614b56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ MapLibre welcomes participation and contributions from everyone. Please read [`C

## main

## (unreleased)

- Temporary workaround for map display freeze / stutter when using annotation views with Metal backend. [Issue 2117](https://github.com/maplibre/maplibre-native/issues/2117) fixed by [PR 2148](https://github.com/maplibre/maplibre-native/pull/2148)

## 6.2.0

- Add support for [multi sprites](https://github.com/maplibre/maplibre-native/pull/1858). More information on this feature can be found in the [Style Spec Documentation](https://maplibre.org/maplibre-style-spec/sprite/#multiple-sprite-sources).
Expand Down
2 changes: 1 addition & 1 deletion platform/ios/app/MBXAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ @implementation MBXAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifndef MLN_DISABLE_LOGGING
#ifndef MLN_LOGGING_DISABLED
[MLNLoggingConfiguration sharedConfiguration].loggingLevel = MLNLoggingLevelFault;
#endif
[MLNSettings useWellKnownTileServer:MLNMapTiler];
Expand Down
2 changes: 1 addition & 1 deletion platform/ios/benchmark/MBXBenchAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ @implementation MBXBenchAppDelegate
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

#ifndef MLN_DISABLE_LOGGING
#ifndef MLN_LOGGING_DISABLED
[MLNLoggingConfiguration sharedConfiguration].loggingLevel = MLNLoggingLevelFault;
#endif

Expand Down
15 changes: 8 additions & 7 deletions platform/ios/src/MLNMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6974,17 +6974,14 @@ - (void)updateAnnotationViews

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

// 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(coordinate, coordinateBounds))
{
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
}
else
if (!MLNCoordinateInCoordinateBounds(annotation.coordinate, coordinateBounds))
{
if (annotationView.layer.animationKeys.count > 0) {
continue;
Expand All @@ -6995,7 +6992,11 @@ - (void)updateAnnotationViews
adjustedCenter.x = -CGRectGetWidth(self.frame) * 10.0;
annotationView.center = adjustedCenter;

[self enqueueAnnotationViewForAnnotationContext:annotationContext];
// 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
}
}
}
Expand Down

0 comments on commit 9614b56

Please sign in to comment.