3

So for our maps, we are using MapKit. We overlay a layer using MKPolygons above the map. This feature has been working since iOS15 but since 16.1 we get the following error and the app freezes (does not crash).

  • [VKDefault] Exceeded Metal Buffer threshold of 50000 with a count of 50892 resources, pruning resources now (Time since last prune:6.497636): Assertion with expression - false : Failed in file - /Library/Caches/com.apple.xbs/Sources/VectorKit/src/MDMapEngine.mm line - 1363

  • Metal API Validation Enabled [PipelineLibrary] Mapping the pipeline data cache failed, errno 22

Another interesting log is the following

  • [IconManager] No config pack found for key SPR London Landmarks

Any idea how to manually clear the metal cache?

t.ios
  • 1,024
  • 12
  • 18
  • Seems to be an issue present with or without polygons. Someone else posted below a comment I made and found the same issue, without polygons https://stackoverflow.com/a/74316787/2472466 – t.ios Nov 09 '22 at 23:00

2 Answers2

5

There seems to be a problem related to the number of MKOverlayRenderers making draw calls. Having more than a few seems to trigger this issue. Using MKMultiPolyline/Polygon seems to be a workaround but that does not work if you need to support iOS 12 or style the lines and polygons independently.

CJiOS
  • 106
  • 1
  • 6
  • 2
    For me using a MKMultiPolyline renderer seems to have fixed the issue. Thank you! – finn Nov 22 '22 at 12:51
  • @cjnorris @finn My project already uses `MKPolylineRenderer`, `MKPolygonRenderer`, and `MKMultiPolygonRenderer` but have started seeing the app freeze completely since iOS 16. Would you be able to share sample code to help me understand where I might be going wrong with this at all? Thanks – mylogon Nov 23 '22 at 14:47
  • 2
    @mylogon I think the solution right now is to only use MKMultiPolygonRender and MKMultiPolylineRender, i.e. batching as many of your polygons and polylines together. In my testing I experience crashes when reaching only a couple of 100 renderers. – CJiOS Nov 24 '22 at 09:11
  • @mylogon not sure if you already fixed your issue, but I basically consolidated all similar polygons into one `MKMultiPolygon` – derickito Dec 13 '22 at 23:44
  • 2
    @derickito Thanks. This looks to be the official advice given to me by Apple DTS support too. Apparently iOS 16 mapkit has gained a lot of extra details and features (overhead), so this renderer performance issue is more likely to show on iOS 16 compared to previous releases. – mylogon Dec 14 '22 at 11:59
  • I can confirm, that using MKMultiPolylineRenderer solved the issue. It seems that if you have several hundred of MKPolylineRenderers on iOS 16, then Metal will break. – gklka Jan 27 '23 at 18:25
  • It looks like Apple is aware at least. The iOS 16.4 Beta might actually fix the issue – CJiOS Feb 17 '23 at 08:44
1

I was reading through this Apple Developer thread: Drawing MKPolylines on map make app unresponsive. Anybody else have this problem ? and I think this answer could be interesting for you to find a solution for your problem. As I am currently also working on it, I will let you know when I have a solution.

Tobsmaster
  • 11
  • 5