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]: Rerouting occasionally skips most waypoints when the wrong direction exists on the route. #4509

Closed
treacher opened this issue Jul 24, 2023 · 3 comments
Labels
bug Something isn’t working

Comments

@treacher
Copy link

treacher commented Jul 24, 2023

Mapbox Navigation SDK version

2.14.0

Steps to reproduce

I've attached an example repository that has a minimum set of code required to reproduce the issue: https://github.com/treacher/MapboxRoutingIssue

The project sets up explicit waypoints (seperate legs as false) and the requirement is for each of those waypoints to be passed no matter what during navigation. This seems to be flakey in that sometimes it follows this rule and sometimes it doesn't when the wrong turn you take lands you on a later part of the route.

I've been following: https://docs.mapbox.com/ios/navigation/examples/custom-server/ however I have not been able to get Mapbox to strictly make sure the driver passes through all waypoints.

There could be a configuration setting I'm missing or it could be an issue with the directions API. I haven't been able to get any logs as strangely it more often than not works when my phone is plugged into my laptop. When my phone is not plugged into my laptop it seems to fail more frequently.

Below is an attached video reproducing this issue:

video-bug-mapbox.mov

Hopefully this provides enough context, more than happy to provide more.

Expected behavior

In the video posted in the steps to reproduce my expectation would be that instead of skipping the waypoints it would keep the route going and ask me to go through the roundabout at the end of the video to pass through the first waypoint.

Here is an example video of what should happen (and does happen sometimes):

bug-mapbox-working.mov

Actual behavior

As can be seen in the video, it cuts the route short and skips a around 2-3 waypoints.

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

repeatable

@treacher treacher added the bug Something isn’t working label Jul 24, 2023
@kried
Copy link
Contributor

kried commented Jul 24, 2023

Hi @treacher

The reason why some waypoints are skipped might be hidden in the implementation details of remainingWaypoints(among:) implementation. We'll investigate in detail the reason for this behavior.

As a temporary workaround, could you please use waypoints that separate legs?
waypoint.separatesLegs = true
Then the waypoint won't get skipped.


Could you please also clarify what is the scenario you're trying to achieve? Is it a usage of a custom backend to provide the route for you? The purpose of the example you referenced is to show how to provide custom, a "third-party" route received from another provider. There is no need to explicitly call Directions.shared.calculate(newRouteOptions) in reroute delegate method if you use Directions as a provider for your routes.

@treacher
Copy link
Author

treacher commented Jul 25, 2023

The reason why some waypoints are skipped might be hidden in the implementation details of remainingWaypoints(among:) implementation. We'll investigate in detail the reason for this behavior.

Hey @kried, thank you for the fast response! I did wonder if something was going on with that function. My initial suspicion was that if you'd travelled far enough off the original route that when using the distance travelled to work out how far along the course you are that it could think you've gone past waypoints that you hadn't gone past yet. My guess is that there can be some variance in distance travelled and that might be why sometimes it sends me back the right way and other times it ends the course early. But it's strange because in the times that it did work as I would expect it to, none of the waypoints had been removed when calling routeProgress.reroutingOptions(from: location) which left me a bit confused.

From what I could read it seems as though whether you've passed a via waypoint is not stored in state and currently it's calculated on the assumption you've mostly followed the originally laid our route.

As a temporary workaround, could you please use waypoints that separate legs?
waypoint.separatesLegs = true
Then the waypoint won't get skipped.

I'm unable to use this as this announces that you've reached a destination each time you've passed a waypoint. I'm currently creating custom bike courses where I want to make sure each waypoint is passed so that I'm able to control the route shape. If cyclists are using the app and it tells them that they've arrived at their destination every 3 minutes it might get quite confusing as the waypoints are used to shape the route and are not that far between each other at times. Is there a way to customise this so that this is not announced and that you can remove the numbers that show on the path? Or is that essentially what separatesLegs is for?

Could you please also clarify what is the scenario you're trying to achieve? Is it a usage of a custom backend to provide the route for you? The purpose of the example you referenced is to show how to provide custom, a "third-party" route received from another provider. There is no need to explicitly call Directions.shared.calculate(newRouteOptions) in reroute delegate method if you use Directions as a provider for your routes.

Great question, I have a JSON file with a predefined set of courses for different locations. Each course is essentially an array of coordinate values. When the app loads, it will use whatever course you have selected and start navigation from your current location. In this case it sounds as though I'm not using a third party route. I'm aiming to update the route based on the remaining waypoints and the users current location when rerouting to make sure that I don't have issues with waypoints being skipped on reroute as I don't want the optimal path to be used on reroute, the most important thing is that all waypoints are travelled through. I have ran into the same issue prior to this when using the default implementation for rerouting and I was hoping that if I implemented my own custom rerouting that the issue would go away but it hasn't.

Do you have any code suggestions I could do to improve my existing delegate implementation for the navigation view controller? Or should I go back to using the default rerouting as it's essentially doing the same thing?

Thanks again 🙏

@treacher
Copy link
Author

treacher commented Aug 10, 2023

Hi @kried, I've also noticed while using waypoints with seperate legs the billing seems to be different. I seem to trigger more trips with seperate legs, is that expected?

Edit: The above seems to be expected behaviour as per: #3378

Any updates on the original rerouting issue? We're keen to release our app but this has been a bit of a show stopper 😞.

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

2 participants