mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Performance Issue with drawInMTKView:

Open mmackh opened this issue 1 year ago • 5 comments

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

mmackh avatar Aug 21 '22 07:08 mmackh

@mmackh, @RodrigoSAlves, could you check if Metal API validation is enabled for the scheme? It can be one cause for the performance drop. Screenshot 2022-09-01 at 15 13 51

ZiZasaurus avatar Sep 08 '22 21:09 ZiZasaurus

@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 avatar Sep 09 '22 09:09 RodrigoSAlves

@RodrigoSAlves, @mmackh are you able to provide a public style url so that we can investigate this further?

ZiZasaurus avatar Sep 12 '22 13:09 ZiZasaurus

I've set mapbox://styles/touchgrove/cl70b4lij000f14pndegvdba9 to public

mmackh avatar Sep 12 '22 18:09 mmackh

same here, drawInMTKView consuming between 70-90% of CPU when unchecked Metal API validation I got half percentage

velco-greg avatar Jun 19 '23 16:06 velco-greg