Skip to content

Fix ReplayRouteSession route state #6675

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

Merged
merged 3 commits into from
Dec 8, 2022
Merged

Fix ReplayRouteSession route state #6675

merged 3 commits into from
Dec 8, 2022

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Dec 2, 2022

Description

Fixing issues in ReplayRouteSession.

  • The routes observer was never unregistered.
  • Alternative route selection resets replay to the beginning.
  • DropInUi changing portrait and landscape modes resets replay to the beginning.

More details

Here is a similar issue where we added Alternative Route support in the ReplayProgressObserver. #5586. Essentially, when the route changes it needs to calculate the distanceTraveled and skip some replay events. The ReplayProgressObserver uses an indexAlong function, where the new way can use the new memory efficient ReplayPolylineDecodeStream.skip.

There is probably a leaking routeProgressObserver in the last beta for anything using ReplayRouteSession. I found it while digging into the issues. I've added a test to cover it. It was registered in onAttached, and not unregistered in onDetached. Simple fix.

The DropInUi fix is slightly lucky, because the ReplayRouteSession is not meant to carry information from onDetatched->onAttached. The TripSessionComponent is tied to the NavigationView lifecycle, so the configuration changes trigger onDetached/onAttached events. I'm considering the alternative route fix the true fix, and DropInUi a lucky beneficiary. This is also how we discovered the ReplayRouteSession issue. More details below.

More more details

The original approach uses the RoutesObserver to decide the current route #6636. This new approach uses the RouteProgressObserver in a way that is similar to ReplayProgressObserver. This decision is to support DropInUi, the behavior of the callbacks act in such a way that information can be carried from onDetatched/onAttached. I am in favor of making it so onDetached does not happen when a configuration changes, but that will require changes to TripSessionComponent.

I have been thinking about how to handle configuration changes with MapboxNavigationObserver, there is a draft here #6484. We can design certain observers to be aware when configurations are changing and maintain state while it is happening. I'm not excited by it because a configuration change does not mean the observer will be re-attached, in which case the state can leak. It feels better to attach the observer to a better lifecycle, such as the Application CarAppLifecycle or ViewModel. Or other ideas.

@kmadsen kmadsen requested a review from a team as a code owner December 2, 2022 02:27
@kmadsen kmadsen force-pushed the km-ReplayRouteSession-fix branch from 4cea25b to ce47aaf Compare December 2, 2022 02:28
@kmadsen kmadsen force-pushed the km-ReplayRouteSession-fix branch 2 times, most recently from 970bd39 to 3108291 Compare December 2, 2022 02:53
@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Merging #6675 (e0065a4) into main (88b9076) will decrease coverage by 0.01%.
The diff coverage is 75.75%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #6675      +/-   ##
============================================
- Coverage     72.49%   72.48%   -0.02%     
- Complexity     5417     5420       +3     
============================================
  Files           764      764              
  Lines         29484    29497      +13     
  Branches       3500     3501       +1     
============================================
+ Hits          21374    21380       +6     
- Misses         6712     6714       +2     
- Partials       1398     1403       +5     
Impacted Files Coverage Δ
...on/core/replay/route/ReplayPolylineDecodeStream.kt 89.47% <66.66%> (-7.67%) ⬇️
...navigation/core/replay/route/ReplayRouteSession.kt 71.42% <76.66%> (-1.42%) ⬇️

@kmadsen kmadsen force-pushed the km-ReplayRouteSession-fix branch from 4e1b977 to e0065a4 Compare December 8, 2022 16:56
@kmadsen kmadsen merged commit 5851598 into main Dec 8, 2022
@kmadsen kmadsen deleted the km-ReplayRouteSession-fix branch December 8, 2022 18:03
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.

6 participants