Loading a PNG image as an overlay on the MapView (Xcode 14 vs. 13 builds)

In our application, we are adding an image overlay of a building on an instance of the MapView. The image overlay conforms to MKOverlay and the renderer of this overlay is an instance of MKOverlayRenderer and required functions. Our application has been written in Objective-C. When we were using Xcode 13 to build our application it was working fine without any problem on devices with iOS 16. As soon as we upgraded the Xcode version to 14, it began to exhibit a new behavior on devices running iOS 16. There is a positioning circle which shows the user location on the mentioned overlay, and this positioning circle is an instance of MKAnnotationView. There is also another circle around the user location which indicates the uncertainty in the user location and this second circle is an instance of MKCircle. In the previous build version, these two circles move with each other when there are any changes in user location coordinates without any lag or synchronization problem. Beginning with the new builds with Xcode 14, the mentioned movement becomes laggy on iOS 16 and there is a synchronization problem with these circles which has never been observed in builds with Xcode 13 on iOS 16. The same code but once built with Xcode 13 does not have this problem but when it is built with Xcode 14 we can observe this issue. We thought that it was the problem of the Uncertainty circle but it is not related to it because when we removed the building overlay (the PNG image overlay) we could not see this synchronization problem once we loaded that image overlay on the map, the problem can be observed.

We have tried lots of different solutions mentioned below but none of them worked. To confirm, we only exhibit this behavior with builds created with Xcode 14 on devices running iOS 16 (this behavior cannot be seen on iOS 15).

  • Below is the list of flags I have added in Apple Clang - Custom Compiler Flags section of the Venue Project in Xcode Build Settings:

    • -ObjC++ -fno-exceptions -stdlib=libc++ -fno-objc-msgsend-selector-stubs

    • -Wl -objc_stubs_small (both in Apple Clang - Custom Compiler Flags and Linking - Other Linker Flags).

  • Change the way that the PNG file is loaded:

NSString *imagePath = \\ some path;
@autoreleasepool {
    @try {
        NSURL *imageURL = [[NSURL alloc] initFileURLWithPath:imagePath];
        NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL options:NSDataReadingUncached error:NULL];
        UIImage *image = [[UIImage alloc] initWithData:imageData];
        BuildingOverlayRenderer *buildingRenderer = [[BuildingOverlayRenderer alloc] initWithOverlay:overlay overlayImage:image];
        renderer = buildingRenderer;
    } @catch (id error) {
        NSLog(@"%@", [error localizedDescription]);
    }
}
  • Change the way that the overlay is drawn in Map Overlay Renderer:
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
    CGRect rect = [self rectForMapRect: self.overlay.boundingMapRect];
    UIGraphicsPushContext(context);
    [self.overlayImage drawInRect:rect];
    UIGraphicsPopContext();
    [super drawMapRect:mapRect zoomScale:zoomScale inContext:context];
}
Loading a PNG image as an overlay on the MapView (Xcode 14 vs. 13 builds)
 
 
Q