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

NavigationTelemetry update cue for changing configurations #648

Merged
merged 5 commits into from
Jan 18, 2018

Conversation

danesfeder
Copy link
Contributor

Sometimes the session state is updated with a new UUID - this should never happen, so should set it once in the builder()

cc @ericrwolfe

@danesfeder danesfeder added the bug Defect to be fixed. label Jan 12, 2018
@danesfeder danesfeder self-assigned this Jan 12, 2018
@ericrwolfe
Copy link
Contributor

Hrmm I think we originally had something like this so that if someone were to arrive at a destination, then update the route and start navigating again, it'd start a new session (with a new depart event). We'll probably want to change this at some point with separate navigation.open and navigation.depart events.

That being said, why would startNavigation be called and reset the session ID after arrival but before cancel?

@danesfeder danesfeder changed the title Set SessionState identifier in builder NavigationTelemetry update cue for changing configurations Jan 16, 2018
@danesfeder
Copy link
Contributor Author

@ericrwolfe I think the issue here was how we look at configuration changes in NavigationTelemetry. We are currently using NavigationService#onConfigurationChange callback. This will always fire when the screen rotates but it will also fire during other configuration changes that don't necessarily mean the activity is being completely destroyed.

So what could be happen is NavigationService#onConfigurationChange could be called when the soft keyboard opens or closes, or device locale changes, etc. and telem would think this is a configuration change and get out of sync because the activity isn't actually being destroyed.

I've updated this PR to use our lifecycle monitor class which has access to the activity that launches the NavigationService and thus Activity#isChangingConfigurations which we check in Activity#onDestroy callback.

@ericrwolfe
Copy link
Contributor

@danesfeder Fortunately, we were able to see the session ID change in the test app while simulating, so should be easy to verify. Want to run the test app with these changes and ensure the session ID stays consistent all the way from depart -> arrive -> cancel?

@@ -69,8 +71,10 @@ protected void onDestroy() {
public void onNavigationReady() {
NavigationViewOptions.Builder options = NavigationViewOptions.builder();
options.navigationListener(this);
extractRoute(options);
extractCoordinates(options);
if (!isConfigurationChange) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericrwolfe this prevents the UI from calling MapboxNavigation#startNavigation twice (we already have a cached route in the RouteViewModel)

@@ -55,6 +55,7 @@ public void onActivityPaused(Activity activity) {
@Override
public void onActivityDestroyed(Activity activity) {
if (activity.isFinishing()) {
NavigationTelemetry.getInstance().endSession(activity.isChangingConfigurations());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericrwolfe Now we call NavigationTelemetry#endSession only if the activity is finishing and pass whether it is finishing from a changing config or not.

@@ -169,6 +165,8 @@ void initialize(@NonNull Context context, @NonNull String accessToken,

isInitialized = true;
}
// Setup the listeners
initEventDispatcherListeners(navigation);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericrwolfe the listeners are also added every time we init now instead of the first time. Arrival events weren't firing after rotation because of this (listener would be null).

@danesfeder
Copy link
Contributor Author

@Guardiola31337 @devotaaabel this is ready for 👀 whenever you have time 🚀

@danesfeder danesfeder merged commit 5d8030d into master Jan 18, 2018
@danesfeder danesfeder deleted the dan-telem-timestamps branch January 18, 2018 21:23
@danesfeder danesfeder mentioned this pull request Jan 23, 2018
14 tasks
TranThuong pushed a commit to TranThuong/mapbox-navigation-android that referenced this pull request Jan 26, 2018
* master:
  Update Strings with Transifex Translations (mapbox#657)
  Added embedded navigation example (mapbox#654)
  Release 0.9.0 (mapbox#663)
  Update README.md for 0.9.0 (mapbox#664)
  Add Maneuver type exit rotary constant (mapbox#653)
  Update Maps and Services dependencies  (mapbox#661)
  Add FasterRouteDetector to check for quicker routes while navigating  (mapbox#638)
  Directions API Banner instructions (mapbox#582)
  NavigationTelemetry update cue for changing configurations (mapbox#648)
  Moved WaypointNavigationActivity from the SDK to the test app (mapbox#652)
  Exposes the MapboxMap in NavigationView with a getter method (mapbox#642)
  Add language to NavigationViewOptions with default from RouteOptions (mapbox#635)

# Conflicts:
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants