Skip to content

Upgrade to MapboxNavigationNative 14.1.5#2417

Merged
MaximAlien merged 42 commits into
release-v1.0-pre-registryfrom
maxim-makhun-update-nav-native-to-14.1.0
Jul 6, 2020
Merged

Upgrade to MapboxNavigationNative 14.1.5#2417
MaximAlien merged 42 commits into
release-v1.0-pre-registryfrom
maxim-makhun-update-nav-native-to-14.1.0

Conversation

@MaximAlien
Copy link
Copy Markdown
Contributor

@MaximAlien MaximAlien commented Jun 23, 2020

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

@MaximAlien MaximAlien self-assigned this Jun 23, 2020
@MaximAlien MaximAlien marked this pull request as draft June 23, 2020 21:39
@MaximAlien MaximAlien changed the base branch from master to dersim-davaod-update-nav-native-to-12.0.3 June 23, 2020 21:39
@MaximAlien MaximAlien requested review from 1ec5 and dersim-davaod June 24, 2020 02:26
@1ec5 1ec5 added the build Issues related to builds and dependency management. label Jun 24, 2020
@1ec5 1ec5 added this to the v1.0.0 milestone Jun 24, 2020
@dersim-davaod dersim-davaod force-pushed the dersim-davaod-update-nav-native-to-12.0.3 branch 2 times, most recently from 33d05bb to bfaddb0 Compare June 25, 2020 15:02
@avi-c
Copy link
Copy Markdown
Contributor

avi-c commented Jun 25, 2020

As part of this update we will need to add retrieving and providing a SKU Token from the SDK to Nav Native.

@dersim-davaod dersim-davaod force-pushed the dersim-davaod-update-nav-native-to-12.0.3 branch from a621a07 to eb0f909 Compare June 26, 2020 14:45
Copy link
Copy Markdown
Contributor

@dersim-davaod dersim-davaod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other question that comes from the question above: should we make accuracy threshold lower?

Copy link
Copy Markdown
Contributor

@1ec5 1ec5 Jun 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@MaximAlien MaximAlien Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Leaving accuracy argument, but slightly change it to contain more 'realistic' value, e.g. distance between snappedLocation and last location?
  2. Changing logic in RouteController to apply new flow in nav. native. E.g. somehow detecting that we're in initialized state even though we're currently already in tracking as 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract 0.5 number (and the rest of constants) into separate consts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still in discussion about the best way how to fix this, when finished will address this.

altitude: -1,
horizontalAccuracy: -1,
verticalAccuracy: 0,
verticalAccuracy: 1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please describe what's the reason of the change? Is that important to use 1 value?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d be surprised if anything in MapboxCoreNavigation or MapboxNavigationNative cares about the vertical accuracy field at this point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that make sense to use different timestamp for the test? Otherwise looks like the test does not do the job.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, updated.

XCTAssertEqual(location.altitude, -1)
XCTAssertEqual(location.horizontalAccuracy, -1)
if #available(iOS 13.4, *) {
XCTAssertEqual(fixLocation.bearingAccuracy, 2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Extract values we check into const within "given" section:

Suggested change
XCTAssertEqual(fixLocation.bearingAccuracy, 2)
XCTAssertEqual(fixLocation.bearingAccuracy, expectedBearingAccuracy)

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add description for XCTFail calls?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a possibility that this test might slightly change, will check afterwards.

Comment thread .circleci/config.yml
Comment on lines +209 to +206
name: "Xcode_11.4.1_iOS_12.2"
xcode: "11.4.1"
iOS: "12.2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@MaximAlien MaximAlien Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread .circleci/config.yml
Comment on lines +214 to +210
name: "Xcode_11.4.1_iOS_10.3.1"
xcode: "11.4.1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s OK.

Comment thread MapboxCoreNavigation/FixLocation.swift Outdated
extension FixLocation {
convenience init(_ location: CLLocation) {
var speedAccuracy: NSNumber? = nil
if #available(iOS 10.0, *) {
Copy link
Copy Markdown
Contributor

@Udumft Udumft Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems redundant. MapboxCoreNavigation minimum iOS version is 10.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, check was removed.

Comment on lines +155 to +159
let navigator: Navigator = {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
return Navigator(profile: settingsProfile, customConfig: "")
}()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use self.navigator here instead of initializing a new one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this place navigator is used in static context, probably better to leave it as it is.

}

func testAdvancingToFutureStepAndNotRerouting() {
func testNotReroutingForAllSteps() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per discussion with @SiarheiFedartsou in Slack, for now it's better to treat invalid state as offRoute.

@MaximAlien
Copy link
Copy Markdown
Contributor Author

testDepartRerouteArrive() is failing due to unexpected route status values returned by nav. native. Details can be found here.

@MaximAlien MaximAlien changed the title Update mapbox-navigation-native to 14.1.0. Update mapbox-navigation-native to 14.1.2. Jul 1, 2020
@MaximAlien MaximAlien force-pushed the maxim-makhun-update-nav-native-to-14.1.0 branch from de1e0e3 to 5255591 Compare July 1, 2020 02:40
@MaximAlien MaximAlien marked this pull request as ready for review July 2, 2020 00:56
Copy link
Copy Markdown
Contributor

@avi-c avi-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@1ec5 1ec5 changed the base branch from dersim-davaod-update-nav-native-to-12.0.3 to release-v1.0-pre-registry July 2, 2020 21:56
@1ec5 1ec5 mentioned this pull request Jul 2, 2020
@1ec5 1ec5 changed the title Update mapbox-navigation-native to 14.1.2. Upgrade to MapboxNavigationNative 14.1.3 Jul 2, 2020
Comment thread Example/SettingsViewController.swift Outdated
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."))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would’ve required rerunning scripts/extract_localizable.sh.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for now I've reverted changes back after update to 14.1.4, had to slightly change tests again though.

Comment thread Example/SettingsViewController.swift Outdated
Comment on lines +98 to +99
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."))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

MaximAlien and others added 24 commits July 6, 2020 12:37
…hether user is on route for all steps and removing stepIndex check since it's not deterministic. Rename test to testNotReroutingForAllSteps.
…rror current logic in nav. native 14.1.2. Remove testSnappedLocation as it's duplicated in other tests multiple times.
…ive now contains both 32 and 64 bit architectures.
@MaximAlien MaximAlien force-pushed the maxim-makhun-update-nav-native-to-14.1.0 branch from 27e081f to 694eae3 Compare July 6, 2020 19:51
@MaximAlien MaximAlien merged commit a85e478 into release-v1.0-pre-registry Jul 6, 2020
@MaximAlien MaximAlien deleted the maxim-makhun-update-nav-native-to-14.1.0 branch July 6, 2020 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues related to builds and dependency management.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants