Skip to content

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Jan 10, 2023

Description

Resolves https://mapbox.atlassian.net/browse/NAVAND-320
Resolves #6056

There is an internal requirement to first call stopTripSession before you can call startReplayTripSession. This pull request is fixing that. This will make it so the caller can convert a regular trip session into a replay session.

I'm finding that this issue needs to be resolved before resolving this issue #6794. Anything that observes the trip session state receives rapid changes when enabling replay.

@github-actions
Copy link

github-actions bot commented Jan 10, 2023

Changelog

Features

  • Introduced ViewStyleCustomization.infoPanelGuidelineMaxPosPercent that allows customization of the NavigationView InfoPanel bottom guideline maximum position. Increased default value to 50%. #6792

Bug fixes and improvements

  • Improved MapboxNavigation#startReplayTripSession and ReplayRouteSession so that the previous trip session does not need to be stopped. ⚠️ ReplayRouteSession#onDetached removed the call to stopTripSession. #6817

  • Each newly instantiated MapboxRouteArrowView class will initialize the layers with the provided options on the first render call. Previously this would only be done if the layers hadn't already been initialized. #6466

  • ⚠️ Updated the NavigationView default navigation puck asset. #6678

    Previous puck can be restored by injecting LocationPuck2D with the bearingImage set to com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon drawable:

    navigationView.customizeViewStyles {
        locationPuckOptions = LocationPuckOptions.Builder(context)
            .defaultPuck(
                LocationPuck2D(
                    bearingImage = ContextCompat.getDrawable(
                        context,
                        com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon,
                    )
                )
            )
            .idlePuck(regularPuck(context))
            .build()
    }
  • Fixed an issue with NavigationView that caused info panel to shrink in landscape mode with a full screen theme. #6780

  • Fixed standalone MapboxManeuverView appearance when the app also integrates Drop-In UI. #6774

  • Added guarantees that route progress with RouteProgress#currentState == OFF_ROUTE arrives earlier than NavigationRerouteController#reroute is called. #6764

  • Introduced NavigationViewListener.onSpeedInfoClicked that would be triggered when MapboxSpeedInfoView is clicked upon. #6770

  • Fixed a rare java.lang.NullPointerException: Attempt to read from field 'SpeechAnnouncement PlayCallback.announcement' on a null object reference crash in PlayCallback.getAnnouncement. #6760

  • Fixed an issue where the first voice instruction might have been played twice. #6766

Known issues ⚠️

Other changes

Android Auto Changelog

Features

Bug fixes and improvements

@kmadsen kmadsen force-pushed the km-NAVAND-320-improve-replay-restart branch 4 times, most recently from 797c007 to eeb1f15 Compare January 10, 2023 23:15
@kmadsen kmadsen marked this pull request as ready for review January 10, 2023 23:21
@kmadsen kmadsen mentioned this pull request Jan 10, 2023
@kmadsen kmadsen requested a review from dzinad January 10, 2023 23:23
@kmadsen kmadsen force-pushed the km-NAVAND-320-improve-replay-restart branch from eeb1f15 to ed60c82 Compare January 11, 2023 00:01
@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Merging #6817 (370f0ab) into main (61415ea) will decrease coverage by 0.00%.
The diff coverage is 86.95%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #6817      +/-   ##
============================================
- Coverage     72.64%   72.63%   -0.01%     
+ Complexity     5569     5568       -1     
============================================
  Files           780      780              
  Lines         30104    30101       -3     
  Branches       3553     3556       +3     
============================================
- Hits          21869    21864       -5     
- Misses         6808     6809       +1     
- Partials       1427     1428       +1     
Impacted Files Coverage Δ
...navigation/core/replay/route/ReplayRouteSession.kt 70.78% <ø> (-0.65%) ⬇️
...al/controller/TripSessionStarterStateController.kt 86.66% <ø> (ø)
...ion/core/trip/session/TripSessionLocationEngine.kt 81.81% <71.42%> (-5.69%) ⬇️
.../navigation/core/trip/session/MapboxTripSession.kt 86.57% <100.00%> (-0.08%) ⬇️
...igation/dropin/tripsession/TripSessionComponent.kt 85.71% <100.00%> (+1.26%) ⬆️

}
tripSessionLocationEngine.startLocationUpdates(withReplayEnabled, onRawLocationUpdate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we need to call NativeNavigaot#resetRideSession so that native navigator doesn't consider first location updates from new location engine as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 yeah. A new location engine seems like a good reason to reset. I'm hesitant, should it go inside the startTripSession? Let's consider it in another change. The caller still has the ability to call it or not call it. Right now ReplayRouteSession calls it when the route changes. We can add it there before forcing it everywhere.

private fun MapboxNavigation.resetReplayLocation() {
mapboxReplayer.clearEvents()
resetTripSession {

@kmadsen kmadsen force-pushed the km-NAVAND-320-improve-replay-restart branch from ed60c82 to 0b5430a Compare January 11, 2023 17:24
replayLocationEngine
} else {
navigationOptions.locationEngine
}
locationEngine.requestLocationUpdates(
activeLocationEngine?.requestLocationUpdates(
Copy link
Contributor

Choose a reason for hiding this comment

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

requestLocationUpdates can be invoked multiple times with different callbacks and all of them will receive location updates.
So my question is: is stopping location updates here the right way to go? I mean what if we want to invoke startLocationUpdates twice with different onRawLocationUpdate? Right now the second invocation will cancel the first one.
By the way, having a single locationEngineCallback guarantees that there will be only one location update, but is this designed? Eve if we remove stopLocationUpdates from here the situation won't change: we'll still be getting raw location updates only in the second lambda.
I mean it's not clear from the API that that's the behaviour. So I'm asking whether it's how it's supposed to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is stopping location updates here the right way to go? I mean what if we want to invoke startLocationUpdates twice with different onRawLocationUpdate? Right now the second invocation will cancel the first one.

It is built to manage a single location engine subscription, because it would be sending duplicates if it had more than one subscription. The activeLocationEngine can change based on parameters, so it is unregistering to whatever the previous engine is.

There could be improvements to the logic, but i'm not seeing why it would be needed. Do you see an issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm only saying that it's not obvious how to use this API. It looks like you can invoke startLocationUpdates twice with different callbacks, receive updates to both callbacks and then stop everything via stopLocationUpdates.
As long as we use the API correctly, there is no issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

startReplayTripSession requires stopTripSession, or does it?
4 participants