mapbox / mapbox-maps-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and Metal
https://www.mapbox.com/mapbox-mobile-sdk
Other
469 stars 153 forks source link

Performance Issue with drawInMTKView: #1537

Open mmackh opened 2 years ago

mmackh commented 2 years ago

Environment

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
ZiZasaurus commented 2 years ago

@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
RodrigoSAlves commented 2 years ago

@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.

ZiZasaurus commented 2 years ago

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

mmackh commented 2 years ago

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

velco-greg commented 1 year ago

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