Problem: The MKPolyline is not displayed on the screen in the scenario described below.
Using Swift I have added a MapKit MapView MKTileOverlay and try add, and display, a Polyline on top of it using: mapView.addOverlay(tracklogPolyline)
mapView.addOverlay(tracklogPolyline, level: MKOverlayLevel.aboveLabels)
I also tried "let overlays = self.mapView.overlays" followed by "self.mapView.insertOverlay(self.homeNavRoute.polyline, above: overlays[overlays.count-1])"
Above mentioned works OK on my Xcode IOS 14.1 simulator and on IOS 13.7 hardware. It FAILS on IOS 14.1 hardware, both on iPhone (for example iPhone XS) and iPad.
Debugging info:
MapView.overlays (let overlays = mapView.overlays) shows that the 2 expected overlays are present, one MKTileOverlay at overlays[0] and the MKPolyline on overlays[1] so that is good. But as stated above the MKPolyline fails to show on IOS 14.1 iPhone and iPad. I am using the regular out of the box renderer; MKPolylineRenderer(overlay: overlay)
Also:
When I display the MKPolyline without adding the MKTileOverlay it works OK in all cases.
I am using Xcode 12.1 to build and run the code.
Question1: Is this a known bug?
Question2: What is the solution ?
Post
Replies
Boosts
Views
Activity
I need to remove a Polyline and replace it by a new one on my mapView about every 2 seconds. The Polyline is correctly removed and added to the screen so that is great. But I see the app memory use increase by about 5 mb per minute. This results in the app becoming very slow and unresponsive. I see the problem on the IOS 14.2 simulator and hardware (iPhone and iPad). On my 13.4 simulator this problem does occur and all works fine without memory leaking. Below run the the steps to reproduce in a loop:
1
create a regular polyLine with about 50 entries
polyLine.title = "polyLine"
2
mapView.addOverlay(PolyLine)
3
let allOverlays = mapView.overlays
for overlay in allOverlays {
if (overlay.title == "polyLine") {
mapView.removeOverlay(overlay)
}
}
4
mapView.addOverlay(PolyLine)
Note: I see the same problem when navigation routes (that is also using Polyline overlay) are recreated. So it looks like MapView graphically works ok but is not releasing memory after mapView.removeOverlay(overlay) is called.
Here is some output from instruments/leaks pointing to VectorKit:
MTLSimTexture 4048 < multiple > 1,48 MiB MTLSimDriver _77-[MTLSimTexture newTextureViewWithPixelFormatInternal:isInternalTextureView:]block_invoke
Malloc 16 Bytes 4083 < multiple > 63,80 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long)
Malloc 144 Bytes 4105 < multiple > 577,27 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long)