stadiamaps / stadiamaps/ferrostar
Speed limit (and road name; maybe other props too) gets stuck/view remains after navigation ends
- Dominant language
- Kotlin
- Stars
- 419
- Forks
- 81
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 7
Description
Expected behavior: when resetting navigation state to `nil`, the navigation-specific elements of the UI should disappear. The speed limit view currently remains. It appears to be something broken with the plumbing for getting these updates through.
I have confirmed via `NSLog` debugging that the speed limit state update is indeed processed through the Combine pipeline in `AnnotationPublisher` (under the `if let mapSpeedLimit` block). However, it does not seem to come back around to SwiftUI, since the `navigationSpeedLimit` modifier is not re-invoked with the new value.
```diff
diff --git a/Package.swift b/Package.swift
index 96e0af1..fe80627 100644
--- a/Package.swift
+++ b/Package.swift
@@ -5,7 +5,7 @@ import PackageDescription
let binaryTarget: Target
let maplibreSwiftUIDSLPackage: Package.Dependency
-let useLocalFramework = false
+let useLocalFramework = true
let useLocalMapLibreSwiftUIDSL = false
if useLocalFramework {
diff --git a/apple/Sources/FerrostarCore/Annotations/AnnotationPublisher.swift b/apple/Sources/FerrostarCore/Annotations/AnnotationPublisher.swift
index 6e03871..e36c1ed 100644
--- a/apple/Sources/FerrostarCore/Annotations/AnnotationPublisher.swift
+++ b/apple/Sources/FerrostarCore/Annotations/AnnotationPublisher.swift
@@ -50,15 +50,26 @@ public class AnnotationPublisher: ObservableObject, Annot
// automatically when the Published instance deinitializes. Because of this, the assign(to:) operator
// doesn’t return an AnyCancellable that you’re responsible for like assign(to:on:) does."
+ // FIXME: Something wrong here?
navigationState
.map(decodeAnnotation)
.receive(on: DispatchQueue.main)
- .assign(to: &$currentValue)
+// .assign(to: &$currentValue)
+ .sink { [weak self] annotation in
+ NSLog("3 Annotation sink: \(annotation)")
+ self?.currentValue = annotation
+ }
+ .store(in: &cancellables)
if let mapSpeedLimit {
$currentValue
.map(mapSpeedLimit)
- .assign(to: &$speedLimit)
+// .assign(to: &$speedLimit)
+ .sink { [weak self] speedLimit in
+ NSLog("1 Speed Limit sink: \(speedLimit)")
+ self?.speedLimit = speedLimit
+ }
+ .store(in: &cancellables)
}
}
diff --git a/apple/Sources/FerrostarCore/Annotations/Models/ValhallaOSRMAnnotation.swift b/apple/Sources/FerrostarCore/Annotations/Models/ValhallaOSRMAnnotation.swift
index 79ab5b3..7a0bc8f 100644
--- a/apple/Sources/FerrostarCore/Annotations/Models/ValhallaOSRMAnnotation.swift
+++ b/apple/Sources/FerrostarCore/Annotations/Models/ValhallaOSRMAnnotation.swift
@@ -31,11 +31,12 @@ public extension AnnotationPublisher {
/// - Parameter onError: An optional error closure (runs when a `DecoderError` occurs)
/// - Returns: The annotation publisher.
static func valhallaExtendedOSRM(
- onError: @escaping (Error) -> Void = { _ in }
+ onError: @escaping (Error) -> Void = { e in NSLog("Error parsing annotation: \(e)") }
) -> AnnotationPublisher {
AnnotationPublisher(
mapSpeedLimit: {
- $0?.speedLimit?.measurementValue
+ NSLog("0 Speed limit: \($0?.speedLimit?.measurementValue)")
+ return $0?.speedLimit?.measurementValue
},
onError: onError
)
diff --git a/apple/Sources/FerrostarSwiftUI/ViewModifiers/SpeedLimitViewModifier.swift b/apple/Sources/FerrostarSwiftUI/ViewModifiers/SpeedLimitViewModifier.swift
index c5a0211..fa7ed86 100644
--- a/apple/Sources/FerrostarSwiftUI/ViewModifiers/SpeedLimitViewModifier.swift
+++ b/apple/Sources/FerrostarSwiftUI/ViewModifiers/SpeedLimitViewModifier.swift
@@ -20,6 +20,7 @@ public extension SpeedLimitViewHost {
speedLimitStyle: SpeedLimitView.SignageStyle
) -> Self {
var newSelf = self
+ NSLog("2 New Speed limit: \(speedLimit), \(speedLimitStyle)")
newSelf.speedLimit = speedLimit
newSelf.speedLimitStyle = speedLimitStyle
return newSelf
```
Contributor guide
Research direction
Start in apple/Sources/FerrostarCore/Annotations/AnnotationPublisher.swift and trace the navigationState, currentValue, and speedLimit Combine publishers, then inspect apple/Sources/FerrostarSwiftUI/ViewModifiers/SpeedLimitViewModifier.swift. Use the ValhallaOSRM annotation mapping in apple/Sources/FerrostarCore/Annotations/Models/ValhallaOSRMAnnotation.swift as the update source. Done means resetting navigation state to nil removes the speed-limit view and other navigation-specific UI after navigation ends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100