mapbox-maps-ios
mapbox-maps-ios copied to clipboard
Performance Issue with drawInMTKView:
Environment
- Xcode version: 13.4.1
- iOS version: 15.6 & 16
- Devices affected: All
- Maps SDK Version: 10.6
Observed behavior and steps to reproduce
On the initial load (without caching), flying a camera with a fixed duration will cause frame drops. This is sometimes also apparent when panning. Below is the code I'm using:
let cameraOptions = CameraOptions(center: .init(latitude: event.lat, longitude: event.long), zoom: 10)
self.mapView.camera.fly(to: cameraOptions, duration: 0.9)
Expected behavior
Consistent 60fps performance on up-to date hardware
Notes / preliminary analysis
It seems some drawing code is spending a significant time on the main thread causing frame drops. The style URI we're using: mapbox://styles/touchgrove/cl70b4lij000f14pndegvdba9
Additional links and references
![Screenshot 2022-08-20 at 15 27 48](https://user-images.githubusercontent.com/948693/185780514-9da61471-c5f8-4607-a663-942b9e02316e.png)
@mmackh, @RodrigoSAlves, could you check if Metal API validation is enabled for the scheme? It can be one cause for the performance drop.
@ZiZasaurus Thanks for taking a look. I disabled the Metal API validation option and did not see a significant decrease in the CPU utilisation. While running the Examples app with same device as my initial tests, it seemed to decrease CPU utilisation by 1% or 2%. While running my app with the same device, it also seemed to decrease at most 3% to 4%. The profiler shows the same pattern.
@RodrigoSAlves, @mmackh are you able to provide a public style url so that we can investigate this further?
I've set mapbox://styles/touchgrove/cl70b4lij000f14pndegvdba9 to public
same here, drawInMTKView consuming between 70-90% of CPU when unchecked Metal API validation I got half percentage