Upgrade to MapboxNavigationNative 14.1.5#2417
Conversation
33d05bb to
bfaddb0
Compare
|
As part of this update we will need to add retrieving and providing a SKU Token from the SDK to Nav Native. |
a621a07 to
eb0f909
Compare
dersim-davaod
left a comment
There was a problem hiding this comment.
Consider some questions/comments:
| XCTAssertEqual(navigation.router.location!.coordinate.latitude, firstCoordinateOnUpcomingStep.latitude, accuracy: 0.0005, "User is snapped to upcoming step when moving") | ||
| XCTAssertEqual(navigation.router.location!.coordinate.longitude, firstCoordinateOnUpcomingStep.longitude, accuracy: 0.0005, "User is snapped to upcoming step when moving") | ||
| // User is snapped to upcoming step when moving | ||
| XCTAssertEqual(navigation.router.location!.coordinate.latitude, firstCoordinateOnUpcomingStep.latitude, accuracy: 0.005, "Latitudes should be almost equal") |
There was a problem hiding this comment.
First, I thought the rerouting algorithm threats legs and steps with new rules, but eventually I had to make the similar changes as coordinates within the route have "almost equality" now.
The question is: is that ok?
Did these tests work fine earlier? If so, I'm not sure why the threshold for accuracy is appeared. Want to make sure the introducing the check against specific accuracy is applicable here. @1ec5 probably you can shed some light?
There was a problem hiding this comment.
The other question that comes from the question above: should we make accuracy threshold lower?
There was a problem hiding this comment.
Based on this table, I think a difference of 0.005° longitude is more than 100 meters off at the latitudes in this test fixture, whereas 0.0005° is within a dozen meters or so. So I think the accuracy threshold does need to be lower, maybe nearly as low as it was previously.
There was a problem hiding this comment.
In previous versions of nav. native right after starting navigation initialized routeState was returned by RouteController. This meant that rawLocation was used, which is last location, as a result no accuracy checks were needed at that time. Example with routeState values with 3 locations:
1. Current route state: initialized
2. Current route state: initialized
3. Current route state: tracking
As per discussion with @SiarheiFedartsou in nav. native 14.1.0 active guidance logic was changed and now initialized state is only returned in setRouteForRouteResponse(_:route:leg:) (I've checked to make sure and that's correct). This means that now route state has such sequence:
1. Current route state: tracking
2. Current route state: tracking
3. Current route state: tracking
This means that instead of rawLocation we'll be using snappedLocation because of such logic in RouteController:
var snappedLocation: CLLocation? {
let status = navigator.getStatusForTimestamp(Date())
guard status.routeState == .tracking || status.routeState == .complete else {
return nil
}
return CLLocation(status.location)
}
...
public var location: CLLocation? {
return snappedLocation ?? rawLocation
}Since snappedLocation is returned from MBNavigator it explains the fact that last location and snappedLocation are not the same (that is the reason accuracy was introduced). I can see two solutions for now:
- Leaving accuracy argument, but slightly change it to contain more 'realistic' value, e.g. distance between
snappedLocationand last location? - Changing logic in
RouteControllerto apply new flow in nav. native. E.g. somehow detecting that we're ininitializedstate even though we're currently already intrackingas per status returned from nav. native.
I might still miss some pitfalls, so if you have any ideas please let me know.
@1ec5, I'd really appreciate your thoughts regarding this.
There was a problem hiding this comment.
Thanks for the comprehensive analysis!
Seems the first option is quicker, but it looks more like cutting the corner.
Should we spend time on trying to update the RouteController?
There was a problem hiding this comment.
I've updated tests to use original accuracy of 0.0005° for coordinates and added distance check between coordinates (set to default accuracy of 1 meter). Had to update several tests to reflect current behavior of logic in nav. native 14.1.2. Please check updated comments in changed tests.
| let fromLocation = notification.userInfo![RouteController.NotificationUserInfoKey.locationKey] as? CLLocation | ||
| return fromLocation == testLocation | ||
|
|
||
| XCTAssertTrue(fromLocation == testLocation) |
There was a problem hiding this comment.
Should we make it as a different test?
So one test checks for notification, the other one checks the notification is bearing expected payload. WDYT?
Probably not the scope for the current PR.
There was a problem hiding this comment.
I've added XCTAssertTrue instead for plain return value to see where test fails more easily. Previously it wasn't really obvious since in case if false is returned expectation would fail with timeout.
| let _ = notification.userInfo![RouteController.NotificationUserInfoKey.routeProgressKey] as! RouteProgress | ||
|
|
||
| return location!.distance(from: rawLocation!) <= 0.0005 | ||
| XCTAssertTrue(location!.distance(from: rawLocation!) <= 0.5) |
There was a problem hiding this comment.
Extract 0.5 number (and the rest of constants) into separate consts?
There was a problem hiding this comment.
Still in discussion about the best way how to fix this, when finished will address this.
| altitude: -1, | ||
| horizontalAccuracy: -1, | ||
| verticalAccuracy: 0, | ||
| verticalAccuracy: 1, |
There was a problem hiding this comment.
Could you please describe what's the reason of the change? Is that important to use 1 value?
There was a problem hiding this comment.
I’d be surprised if anything in MapboxCoreNavigation or MapboxNavigationNative cares about the vertical accuracy field at this point.
There was a problem hiding this comment.
verticalAccuracy, courseAccuracy, speedAccuracy were just recently introduced. I've added values 1, 2, 3 respectively for those properties just for the sake of variety, to see that initializer assigns correct values.
| speed: 18, | ||
| timestamp: Date()) | ||
|
|
||
| XCTAssertEqual(location.timestamp, location.shifted(to: location.timestamp).timestamp) |
There was a problem hiding this comment.
Does that make sense to use different timestamp for the test? Otherwise looks like the test does not do the job.
There was a problem hiding this comment.
Makes sense, updated.
| XCTAssertEqual(location.altitude, -1) | ||
| XCTAssertEqual(location.horizontalAccuracy, -1) | ||
| if #available(iOS 13.4, *) { | ||
| XCTAssertEqual(fixLocation.bearingAccuracy, 2) |
There was a problem hiding this comment.
nit:
Extract values we check into const within "given" section:
| XCTAssertEqual(fixLocation.bearingAccuracy, 2) | |
| XCTAssertEqual(fixLocation.bearingAccuracy, expectedBearingAccuracy) |
?
There was a problem hiding this comment.
Good note, updated test.
| let departEvent = events.filter { $0.event == MMEEventTypeNavigationDepart }.first! | ||
| let rerouteEvent = events.filter { $0.event == MMEEventTypeNavigationReroute }.first! | ||
| let arriveEvent = events.filter { $0.event == MMEEventTypeNavigationArrive }.first! | ||
| guard let departEvent = events.filter({ $0.event == MMEEventTypeNavigationDepart }).first else { XCTFail(); return } |
There was a problem hiding this comment.
nit: add description for XCTFail calls?
There was a problem hiding this comment.
There is a possibility that this test might slightly change, will check afterwards.
| name: "Xcode_11.4.1_iOS_12.2" | ||
| xcode: "11.4.1" | ||
| iOS: "12.2" |
There was a problem hiding this comment.
Various test fixtures are conditionalized by iOS version, based on their file names. So we’ll need to rename or delete and rerecord a slew of test fixtures, similar to what took place in #2427.
There was a problem hiding this comment.
Thanks, fixtures were updated. I've also decided to remove iOS 13.4.1 build job since there is one for 13.5 already (this will allow to speed up build time and prevent adding additional fixtures for 13.4.1).
| name: "Xcode_11.4.1_iOS_10.3.1" | ||
| xcode: "11.4.1" |
There was a problem hiding this comment.
We need to continue to test against iOS 10.x somehow, because the SDK still supports iOS 10.x. On the other hand, it’s fine to drop Xcode 10 support, but we should update the readme to make that clear.
There was a problem hiding this comment.
I've added step to test against iOS 10.3.1. Do you think that's enough? Also another note is that since properties like courseAccuracy were introduced only in iOS 13.4 minimum usable version of Xcode is 11.4.1. Please let me know if that's okay.
| extension FixLocation { | ||
| convenience init(_ location: CLLocation) { | ||
| var speedAccuracy: NSNumber? = nil | ||
| if #available(iOS 10.0, *) { |
There was a problem hiding this comment.
This check seems redundant. MapboxCoreNavigation minimum iOS version is 10.0
There was a problem hiding this comment.
Thanks, check was removed.
| let navigator: Navigator = { | ||
| let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile, | ||
| platform: ProfilePlatform.KIOS) | ||
| return Navigator(profile: settingsProfile, customConfig: "") | ||
| }() |
There was a problem hiding this comment.
Can we use self.navigator here instead of initializing a new one?
There was a problem hiding this comment.
In this place navigator is used in static context, probably better to leave it as it is.
| } | ||
|
|
||
| func testAdvancingToFutureStepAndNotRerouting() { | ||
| func testNotReroutingForAllSteps() { |
There was a problem hiding this comment.
I see that when using nav. native 9.0.4 this test was working non deterministically. E.g. here check for advancing to future step is made only for steps 1 and 3 (why not for all?). When I check steps advancing for all steps I see that stepIndex is not increased for steps other than 1 and 3 (e.g. we remain on stepIndex 1 (instead of 2) for location with index 1 and on stepIndex 3 for locations 4 and 5). Explanation for this is that stepIndex is tied to value stored in nav. native class MBNavigationStatus.
I've modified test to check whether locations in list are on route, I think there is no reliable way to check in what case stepIndex will be increased.
|
|
||
| let status = status ?? navigator.getStatusForTimestamp(location.timestamp) | ||
| let offRoute = status.routeState == .offRoute | ||
| let offRoute = status.routeState == .offRoute || status.routeState == .invalid |
There was a problem hiding this comment.
As per discussion with @SiarheiFedartsou in Slack, for now it's better to treat invalid state as offRoute.
|
|
de1e0e3 to
5255591
Compare
avi-c
left a comment
There was a problem hiding this comment.
The mechanics of this all look good to me. If Minh is happy with the test infrastructure then I think we should merge so we can move forward ASAP and stay more in-sync with Nav Native.
| Settings.directions.configureRouter(tilesURL: tilesURL!) { [weak self] (numberOfTiles) in | ||
| let message = String.localizedStringWithFormat(NSLocalizedString("ROUTER_CONFIGURED_MSG", value: "Router configured with %ld tile(s).", comment: "Alert message when a router has been configured; 1 = number of map tiles"), numberOfTiles) | ||
| Settings.directions.configureRouter(tilesURL: tilesURL!) { [weak self] in | ||
| let message = String.localizedStringWithFormat(NSLocalizedString("ROUTER_CONFIGURED_MSG", value: "Router was configured.", comment: "Alert message when a router has been configured.")) |
There was a problem hiding this comment.
This would’ve required rerunning scripts/extract_localizable.sh.
There was a problem hiding this comment.
Thanks, for now I've reverted changes back after update to 14.1.4, had to slightly change tests again though.
| Settings.directions.configureRouter(tilesURL: tilesURL!) { [weak self] in | ||
| let message = String.localizedStringWithFormat(NSLocalizedString("ROUTER_CONFIGURED_MSG", value: "Router was configured.", comment: "Alert message when a router has been configured.")) |
There was a problem hiding this comment.
This backwards compatibility issue in MapboxNavigationNative was rolled back in v14.1.4, which I think we can upgrade to pretty smoothly from v14.1.3. I guess we might as well bring back the callback argument.
…dding accuracy parameter.
…lizer since iOS 13.4.
…hether user is on route for all steps and removing stepIndex check since it's not deterministic. Rename test to testNotReroutingForAllSteps.
…pboxNavigationTests.
…rror current logic in nav. native 14.1.2. Remove testSnappedLocation as it's duplicated in other tests multiple times.
…4.1.3 (unable to update locally).
This reverts commit 7c34a11.
…ive now contains both 32 and 64 bit architectures.
27e081f to
694eae3
Compare
Due to availability changes in CLLocation API had to drop support of Xcode lower than 11.4.1. Please let me know if that's okay. Other than that there is workaround for architectures handling in nav. native when running pod lint (added in branch for update to 12.0.3).
/ref #2416