mapbox / mapbox/mapbox-maps-ios
High Energy Usage
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: 14.2
- iOS version: 16.3.1
- Devices affected: Iphone
- Maps SDK Version: 10.11.0
## Observed behavior and steps to reproduce
Using SwiftUI i am showing a MapBox Map on my main screen, when presented in xcode energy report i have noticed a very high energy usage coming from using to much GPU after hours of debugging i have finally found out that this behavior happens because of mapbox is being re-rendered way too much, i have used the same implementation as their SwiftUI Example, but i am displaying user location on the map and changing the camera when the user moves, additionally i have implemented Apple Maps and Google Maps to see if its General issue with swiftUI or not, and No its specific to MapBox.
So here are some screenshot of whem i am presenting Mapbox and when i remove just the map layer
When i am displaying the map Notice the GPU Usage:

When i remove just the Map Layer Notice how the GPU Usage drops:

Alternatively using Apple Map Or Google Map doesn't use that much GPU.
## Expected behavior
## Notes / preliminary analysis
So after digging up a little bit more i noticed that with MapBox For some reason calling updateUIView() in the UIViewRepresentable protocol is being called endlessly and very fast which made me think that the GPU usage is because the UI is being redrawn way too much which i am not sure why since with the other map that i experimented with that was not an issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the SwiftUI map implementation, user-location display, and camera updates in Xcode's energy report on iOS 16.3.1 with Maps SDK 10.11.0. Trace the repeatedly called updateUIView() entry point and compare GPU usage with the map layer removed; done means the excessive rendering or its cause is identified and addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100