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

SwiftUI - Override location provider Puck refresh rate

Open nicolasbarb opened this issue 10 months ago • 0 comments

Environment

  • Xcode version: 15.4
  • iOS version: 17.5 > 18.3.1
  • Devices affected: all physicals + simulators
  • Maps SDK Version: 11.10

Observed behavior and steps to reproduce

According Mapbox SwiftUI docs, i transform to a Signal my locations and override LocationProvider proxy.location?.override(locationProvider: mapLocationSignal())

Using basic puck 2D configuration Puck2D(bearing: .heading)

And Viewport as "Follow Puck" .followPuck(zoom: MapConstants.Settings.DEFAULT_ZOOM)

Puck refresh is not fluid at all, my locations are refreshed every 0.05 seconds and puck should be animated from previous location to new location thanks to interpolation.

https://github.com/user-attachments/assets/37ab71d2-39a1-490b-a30c-9a4c07a7a82a

Expected behavior

I expect my puck refresh to be as smooth as my old integration using UIKit system with UIViewRepresentable. As seen in the video the puck is very smooth and satisfying even at maximal zoom.

https://github.com/user-attachments/assets/e02d3f05-5730-444c-ba77-2fdc02e7eac9

Notes / preliminary analysis

i started thinking it was a viewport bug but removing it clearly show that there is a bug in disappearing / appearing puck logic. I tried to log PuckRenderingData which are the interpolated values between 2 locations. Heres a sample where "loc" are real locations and "puck" the interpolated one 📍loc latitude: 45.74135119298924 📍 Puck latitude: 45.74133870265051 📍 Puck latitude: 45.741338892579 📍 Puck latitude: 45.741339083179604 📍 loc latitude: 45.74135119298924

I can clearly see that interpolation is working but nothings pretty on screen.

Also test with AppleLocationProvider implementation with and without overriding, it's better but i can still see some latency in puck refresh.

Is there anything I'm forgetting ?

nicolasbarb avatar Feb 18 '25 14:02 nicolasbarb