Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Navigation spams route alternatives each second #4566

Open
JanTG1 opened this issue Oct 22, 2023 · 3 comments
Open

[Bug]: Navigation spams route alternatives each second #4566

JanTG1 opened this issue Oct 22, 2023 · 3 comments
Assignees
Labels
bug Something isn’t working

Comments

@JanTG1
Copy link

JanTG1 commented Oct 22, 2023

Mapbox Navigation SDK version

2.17.0

Steps to reproduce

Start a step by step navigation which has alternative routes displayed on the mapview. The navigation will startstuttering / flashing the route. Checking the logs will show you that the reroutes get spammed each second.

Expected behavior

The Navigation Controller should do nothing when the user is not moving. No alternatives should be selected or removed.

Actual behavior

The Console spams this:

`[Info, nav-native]: RouteAlternativesControllerImpl::onStatus alternatives=[ ], removed=[ altId=309(routeId=HhZKQhlziKK239kZfzHh9azxoYxAL7zU5UZDwew0jV5awfLuAlvlEQ==_eu-west-1#1) ]

[Info, nav-native]: Requesting online route id 151: https://api.mapbox.com/directions/v5/mapbox/driving-traffic/LINK-REMOVED-FOR-SAFETY
[Info, nav-native]: ParallelHybridRouter::getRoute: Timeout for task with id 141 triggered but request not found
[Info, nav-native]: ParallelHybridRouter::getRoute: Refused to schedule onboard router request as pending request with id 149 has already finished
[Info, nav-native]: RouteAlternativesControllerImpl::setRoutes isAlternativesChanged. alternatives=[ ], removed=[ ]
[Info, navigation-ios/navigation]: Navigator alternative routes has been updated (0 alternatives set).
[Info, nav-native]: OnlineRouter::getRoute req id 151 successfully returns
[Info, nav-native]: Online response id 151 returned 146769 bytes
[Info, nav-native]: RouteAlternativesControllerImpl::setRoutes isAlternativesChanged. alternatives=[ altId=311(routeId=HhZKQhlziKK239kZfzHh9azxoYxAL7zU5UZDwew0jV5awfLuAlvlEQ==_eu-west-1#1) ], removed=[ ]
[Info, navigation-ios/navigation]: Navigator alternative routes has been updated (1 alternatives set).
[Info, navigation-ios/navigation]: Navigator alternative routes has been updated (1 alternatives set).
[Info, nav-native]: RouteAlternativesControllerImpl::onStatus alternatives=[ ], removed=[ altId=311(routeId=HhZKQhlziKK239kZfzHh9azxoYxAL7zU5UZDwew0jV5awfLuAlvlEQ==_eu-west-1#1) ]
[Info, nav-native]: Requesting online route id 152: https://api.mapbox.com/directions/v5/mapbox/driving-traffic/LINK-REMOVED-FOR-SAFETY
[Info, nav-native]: RouteAlternativesControllerImpl::setRoutes isAlternativesChanged. alternatives=[ ], removed=[ ]
[Info, navigation-ios/navigation]: Navigator alternative routes has been updated (0 alternatives set).
[Info, nav-native]: ParallelHybridRouter::getRoute: Timeout for task with id 142 triggered but request not found
[Info, nav-native]: ParallelHybridRouter::getRoute: Refused to schedule onboard router request as pending request with id 150 has already finished
[Info, nav-native]: OnlineRouter::getRoute req id 152 successfully returns
[Info, nav-native]: Online response id 152 returned 146769 bytes
[Info, nav-native]: RouteAlternativesControllerImpl::setRoutes isAlternativesChanged. alternatives=[ altId=313(routeId=HhZKQhlziKK239kZfzHh9azxoYxAL7zU5UZDwew0jV5awfLuAlvlEQ==_eu-west-1#1) ], removed=[ ]`

This just keeps going about once each second, even if the user does nothing, does not touch the screen or move in any way. The Route Layer begins flashing and the map stutters on each reload. I have noticed that it stops once the user manually selects one of the route alternatives. The navigation controller then stops automatically switching alternative.

Is this a one-time issue or a repeatable issue?

repeatable

@JanTG1 JanTG1 added the bug Something isn’t working label Oct 22, 2023
@kried kried self-assigned this Oct 30, 2023
@kried
Copy link
Contributor

kried commented Nov 2, 2023

Hi @JanTG1

Unfortunately, we were not able to reproduce the issue. Did you update from an older SDK version or is it a completely new integration?
Could you please provide a sample to reproduce described behaviour?

@osvaldoln
Copy link

osvaldoln commented Dec 1, 2023

I ma having the same problem while using it with UIViewControllerRepresentable.

struct MBNavigator: UIViewControllerRepresentable {
    var response: RouteResponse
    var options: NavigationRouteOptions
    var manifestOptiVM: ManifestOptiViewModel
    
    func makeUIViewController(context: Context) -> some UIViewController {
        let navigationview = NavigatorController() //NavigationViewController(for: response, routeIndex: 0, routeOptions: options)
        navigationview.maniVM = manifestOptiVM
        return navigationview
    }
    func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
        
    }
}
class NavigatorController: UIViewController {
    var maniVM = ManifestOptiViewModel()
    var viewController: NavigationViewController?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUpView()
    }
    private func setUpView() {
        // Define two waypoints to travel between
        let origin = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), name: "Mapbox")
        let destination = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), name: "White House")
         
        // Set options
        let routeOptions = NavigationRouteOptions(waypoints: [origin, destination])
        let navigationOptions = NavigationOptions(simulationMode: .always)
        Directions.shared.calculate(routeOptions) {[weak self] session, result in
            switch result {
                case .failure(let error):
                    print(error.localizedDescription)
                case .success(let response):
                guard let self = self else { return }
                // Pass the first generated route to the the NavigationViewController
                viewController = NavigationViewController(for: response, routeIndex: 0, routeOptions: routeOptions, navigationOptions: navigationOptions)
                viewController!.delegate = self
                viewController!.modalPresentationStyle = .currentContext
                self.present(viewController!, animated: true, completion: nil)
            }
        }
    }

}
 
extension  NavigatorController: NavigationViewControllerDelegate {
    func navigationViewController(_ navigationViewController: NavigationViewController, didUpdate progress: RouteProgress, with location: CLLocation, rawLocation: CLLocation) {
        self.maniVM.updateLocationData(progress: progress)
    }
    func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) {
        if (canceled) {
            navigationViewController.dismiss(animated: true)
            self.maniVM.dismissnavifation(dismiss: false)
        }
    }
}

@JanTG1
Copy link
Author

JanTG1 commented Jan 22, 2024

@kried sorry for missing your reply! I have since updated the sdk. I am now using "MapboxNavigation', '~> 2.17.0'" and "MapboxMaps', '10.16.1'", but the issue still happens. I have tried debugging on my side but there is absolutely nothing that could be triggering this behaviour. Have you tried checking @osvaldoln's implementation? Would like to know if there is any progress on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

No branches or pull requests

3 participants