mapbox / mapbox/mapbox-maps-ios

SwiftUI - Override location provider Puck refresh rate

Open
#2,293 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

## 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 ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with Puck2D(bearing: .heading), followPuck, and the overridden locationProvider described above. Start by comparing the overridden provider with AppleLocationProvider and inspect the reported PuckRenderingData interpolation and puck disappearing/appearing behavior. Done means identifying and correcting the refresh behavior so the SwiftUI puck renders smoothly at the reported update rate.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.