mapbox-navigation-ios
mapbox-navigation-ios copied to clipboard
[Bug]: Double instructions
Mapbox Navigation SDK version
2.0 rc4
Steps to reproduce
Missed a turn and this started a reroute - so far so good.
but..from that point I started hearing two different instructions.
Expected behavior
hear only one spoken instruction.
Actual behavior
Missed a turn and this started a reroute - so far so good.
but..from that point I started hearing two different instructions.
I've attached a video sample (turn audio on), you can see what happens when I take a turn before the guided turn. It starts two different instructions (one says rashi street and the other one says to stay on alterman street). It stayed like that from that turn till the end of the navigation.
Is this a one-time issue or a repeatable issue?
repeatabl
https://user-images.githubusercontent.com/19625881/136598337-c59da48e-a550-48b4-8232-00c32f6db701.mp4
e
@DiegoResnik I wasn't able to reproduce the issue. It looks like an integration issue. If you could provide a sample that has this issue, we would help investigate and guide you to proper implementation.
@S2Ler this is part of a quite a big app, could you be more specific on where the error could be?
I came here to report almost exactly the same issue. Mine occurs on the second time I start a new NavgiationViewController and Navigation service. I suspect a leak somewhere (probably on my side). I note that NavigationService.deinit is not being reliably called. I will investigate further.
I note that exactly the same code on the old 1.x Navigation SDK worked fine (modulo the required init changes for 2.0).
@samcrawford @DiegoResnik If NavigationService isn't deallocated after NavgiationViewController
dismiss it is a sign of a memory management issue.
You can investigate what exactly keeps NavigationService
alive using Xcode Memory Graph. Remember to turn on Malloc Stack Logging that will help with debugging:
If you find what causes the issue, please let us know so that we can either reduce the possibility of this leak or update the documentation to help developers to not fall into this problem.
If you need a help with investigation, feel free to reach me directly.
FYI, I found the issue was indeed on my side - I had held a strong reference to NavigationViewController. Making this a weak reference resolved it.
@S2Ler : In my case, the navigationview is embeded in a navigationController app, the user can leave the navigation and get back to it. So I want the voice instructions to keep going even if I leave the screen...and when I get back I want the navigationview to continue as it was already loaded. So for this I have a singleton to keep navigationService/response/navigationOptions alive even when the user leaves the navigationview screen...but as I now understand..they are held also by navigationview. how should I handle this reference hell?
@MaximAlien Can you please take a look on this problem?
@S2Ler, I've change the singleton to hold the navigationViewController and not just the navigationService. I guess it is quite expensive, but if navigationService is owned by navigationViewController...it seems the only way to avoid this issue. Do you have a better solution?
@DiegoResnik You can actually pass NavigationService to NavigationViewController
through https://github.com/mapbox/mapbox-navigation-ios/blob/655e2060f852fe1e321b68b290ab35562a2dd30b/Sources/MapboxNavigation/NavigationViewController.swift#L320 or https://github.com/mapbox/mapbox-navigation-ios/blob/655e2060f852fe1e321b68b290ab35562a2dd30b/Sources/MapboxNavigation/NavigationViewController.swift#L306 (using https://github.com/mapbox/mapbox-navigation-ios/blob/655e2060f852fe1e321b68b290ab35562a2dd30b/Sources/MapboxNavigation/NavigationOptions.swift#L47). Will it work? That way it seems you don't need to retain NavigationViewController, it seems. Will it work that way for you?
Hi @S2Ler,
I'll try that out. though I'm thinking to maybe display the "InstructionsBannerView" alone in a banner when I exit the navigation screen, is that something I can/should hold separately or stay with the NavigationViewController?
Also I've noticed once (can't seem to reproduce) that when I tap the x to close and stop the navigation, the voice controller keeps talking. Is this the right way to stop navigation session?
func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) {
if canceled
{
NavigationManager.shared.clearRoute()
}
navigationController?.popToRootViewController(animated: true)
dismiss(animated: false, completion: nil)
}
func clearRoute()
{
if (self.navigationViewController != nil)
{
self.navigationViewController!.voiceController?.speechSynthesizer.stopSpeaking()
self.navigationViewController!.navigationService.stop()
self.navigationViewController!.navigationService.endNavigation(feedback: nil)
}
navService = nil
navOptions = nil
routeOptions = nil
routeResponse = nil
navigationViewController = nil
}