[Bug]: Crash when using multiple waypoints - Thread 1: Assertion failed
Mapbox Navigation SDK version
2.9.0
Steps to reproduce
Use multiple waypoints for the destination. If I call advanceLegIndex, the app crashes. However, in some cases the crash occurs even as the user puck navigates to the waypoint.
Expected behavior
There should not be a crash.
Actual behavior
App crashes with the following error:
Thread 1: Assertion failed
File name: RouteProgress.swift
public var legIndex: Int {
didSet {
assert(legIndex >= 0 && legIndex < route.legs.endIndex)
// TODO: Set stepIndex to 0 or last index based on whether leg index was incremented or decremented.
currentLegProgress = RouteLegProgress(leg: currentLeg)
}
}
Is this a one-time issue or a repeatable issue?
repeatable
I believe this might be similar to #1081
Hi, @nik-bplx! Could you please provide more detail on how to reproduce this crash? Does it crash 100% times? How many waypoints do you use? Could you provide a route sample if possible? Does it crash when advancing on specific leg (last, first, any)? Did you encounter any route-changing events during that trip like re-routing, picking alternative routes, etc.? These answers would help to identify the problem.
It would be also nice to have a history file for such crash (see HistoryRecroding).
Hi, It does not crash 100% of the time. As I said, it's very random. I have typically observed it to crash when using >3 waypoints. Some of the waypoints I was using:
[-122.023306, 37.360792],
[-122.070464, 37.381085],
[-122.069909, 37.407302],
[-121.974796, 37.353317]
I haven't observed any route-related events that might be causing the crash so far.
As for the HistoryRecording, can you help to identify when to start the recording? I.e after the navigation session is started or when I skip the waypoint? Similarily, will the recording persist in case of a crash? Where should the stopRecording be called?
Thank you.
Hi @nik-bplx
[-122.023306, 37.360792], [-122.070464, 37.381085], [-122.069909, 37.407302], [-121.974796, 37.353317]
It looks like we need more information to reproduce the issue, we were not able to reproduce the issue even with provided waypoints.
Could you please take a look at the sample. Do you in your code call advanceLegIndex only for non-final leg, return false in the delegate method navigationViewController:didArriveAt:? Is it possible for you to provide code sample to reproduce the issue?
As for the HistoryRecording, can you help to identify when to start the recording? I.e after the navigation session is started or when I skip the waypoint? Similarily, will the recording persist in case of a crash? Where should the stopRecording be called?
It's better to start recording when the navigation started. In order to get the most data you can then use both approaches:
- to call
stopRecordinginnavigationViewController:didArriveAt:only for the final leg to get a single history file for all legs - to call
stopRecordingand right after againstartRecordingHistoryinnavigationViewController:didArriveAt:to get a separate history file for each leg Both types of files would be useful for us.