Performance issues with MapKit on iOS6

After upgrading to iOS 6, I noticed that performance degradation decreases when you pan or zoom MKMapView with multiple overlays. The application I created has approximately 600 polygonal overlays of different colors and works without restrictions (even on older iOS devices) on iOS 5, now it works very slowly (when zooming and panning) on ​​iOS 6 even on the latest devices.

My guess is that this is due to the fact that in fact the device should dynamically create a map (starting from its vector base), and not just display elements on the screen.

Does anyone have any idea to reduce the delay that occurs when panning or zooming in on a map?

Some additional information, this low frame rate, also occurs during scaling or panning of areas where overlays are not displayed at all on the screen, so this is not related to creating overlays as they appear on the screen.

+4
source share
2 answers

You can try to combine all your linings into one. This can significantly improve performance.

The idea is to create an overlay with a bounding box that spans all your polygons. That way your mapView: viewForOverlay will always be called. Create a property for your overlay that contains all of your polygons. Then, in the drawMapRect: method of your overlay view, check all your polygons to intersect mapRect and cross them out if necessary. This is important because you do not want to draw polygons that are off the screen.

This strategy is based on Apple's own MapKit projects. Check out HazardMap for an example of drawing multiple objects in one MKOverlayView and check out BreadCrumb for an example of how to effectively test polygons to intersect with the current mapRect in the drawMapRect method

+1
source

I have a minimalist demonstration of MapKit technology, and it is noticeably behind when I launch it on iPad 3 with iOS6. Profiling shows that it is connected to the CPU, but only 0.2% of my own code. The big culprits in my case are the rendering of roads, and then the rendering of labels - both made by MapKit. I show downtown San Francisco on a 5 km scale, so there are a lot of roads and shortcuts for rendering.

So, the moral of this story: iOS6 SLOW cards. I can’t say how it compares with iOS5 or iPad 2. But it lags behind, and I do almost nothing on my own.

PS: Open the tools and use Time Profiler. Record + turn around to find your criminals. Then check "hide system libraries" to find out which part of the backlog is your responsibility and MapKit. Then optimize only as needed.

0
source

Source: https://habr.com/ru/post/1440095/


All Articles