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

Remove experimental from MapboxNavigationApp #6143

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Aug 9, 2022

Description

In order to create stable apis for Android Auto and DropInUi, the MapboxNavigationApp framework needs to also be stable. We have also reached a point where it would cause many issues downstream if changes are not backwards compatible.

This also deprecates MapboxNavigationProvider. Adopting MapboxNavigationApp will not break any references to MapboxNavigationProvider because it is used by MapboxNavigationOwner.

cc: @mapbox/navigation-android

@kmadsen kmadsen requested a review from a team as a code owner August 9, 2022 23:32
@kmadsen kmadsen force-pushed the km-remove-experimental-for-MapboxNavigationApp branch from fe92387 to c194f9b Compare August 9, 2022 23:34
@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #6143 (0b6453c) into main (253b03a) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #6143      +/-   ##
============================================
- Coverage     68.90%   68.89%   -0.01%     
  Complexity     4255     4255              
============================================
  Files           639      639              
  Lines         25646    25643       -3     
  Branches       3003     3003              
============================================
- Hits          17671    17668       -3     
  Misses         6828     6828              
  Partials       1147     1147              
Impacted Files Coverage Δ
...ava/com/mapbox/navigation/core/MapboxNavigation.kt 67.66% <ø> (ø)
...mapbox/navigation/core/MapboxNavigationProvider.kt 45.45% <ø> (ø)
.../navigation/core/lifecycle/CarAppLifecycleOwner.kt 83.69% <ø> (-0.18%) ⬇️
...x/navigation/core/lifecycle/MapboxNavigationApp.kt 0.00% <ø> (ø)
...tion/core/lifecycle/MapboxNavigationAppDelegate.kt 91.66% <ø> (-0.23%) ⬇️
...navigation/core/lifecycle/MapboxNavigationOwner.kt 89.47% <ø> (-0.27%) ⬇️

@kmadsen kmadsen force-pushed the km-remove-experimental-for-MapboxNavigationApp branch from c194f9b to fe6409f Compare August 10, 2022 17:03
Copy link
Contributor

@abhishek1508 abhishek1508 left a comment

Choose a reason for hiding this comment

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

Nice!! Glad to see we are moving towards stability.

@dzinad
Copy link
Contributor

dzinad commented Aug 11, 2022

Is there a ticket to update all of our examples?

@Zayankovsky
Copy link
Contributor

Should we somehow discourage users from instantiating MapboxNavigation via its constructor?

@LukasPaczos
Copy link
Member

🚢

Should we somehow discourage users from instantiating MapboxNavigation via its constructor?

A small problem I see with the MapboxNavigationApp is that it's somewhat inherently async. If there's a use-case that would benefit from synchronously getting access to MapboxNavigation, it might be inconvenient to use. Unless MapboxNavigationApp#current guarantees a synchronous access after MapboxNavigationApp#setup? I haven't analyzed the order of lifecycle observer calls to confirm that. If we can provide a good synchronous access, then we should be in a position to deprecate the primary MapboxNavigation constructor.

@tomaszrybakiewicz
Copy link
Contributor

Additionally to deprecating, maybe we should update all MapboxNavigaitonProvider methods to call MapboxNavigationApp? WDYT?

@kmadsen kmadsen force-pushed the km-remove-experimental-for-MapboxNavigationApp branch from c46af8b to 7b095a4 Compare August 11, 2022 20:35
@kmadsen
Copy link
Contributor Author

kmadsen commented Aug 11, 2022

Thanks for comments! Responses are below the comment links.

#6143 (comment) Is there a ticket to update all of our examples?

Not yet, we need a v2.8.0 migration guide. MapboxNavigationApp will be stable as of the v2.8.0 release train, which is currently in alpha. Many apis that make the migration easier are experimental or are built to support deprecated APIs. Declaring stability will help resolve opinions on the details of the migration.

#6143 (comment) Should we somehow discourage users from instantiating MapboxNavigation via its constructor?

This topic has come up before, we are discouraging it. it would also be a SEMVER to prohibit it strictly. I think we are being careful to decide if the public constructor should deprecated. It does add support for a simple synchronous construction as lukas mentioned.

#6143 (comment) MapboxNavigationApp is that it's somewhat inherently async. If there's a use-case that would benefit from synchronously getting access to MapboxNavigation, it might be inconvenient to use.

Adding to this. We are discouraging synchronous creation of MapboxNavigation because it has a lifecycle. But, it is still possible. You can create MapboxNavigation with MapboxNavigationApp synchronously using this specific call order.

mapboxNavigation = MapboxNavigationApp.setup(navigationOptions).attach(lifecycleOwner).current()!!

lifecycleOwner must be in the CREATED state or else current()!! will throw a NPE. This means you can do this in Activity.onStart but you cannot do it in Activity.init or Activity.onCreate because the lifecycle owner is still in the INITIALIZED state. This encourages the use of MapboxNavigationApp.registerObserver.

#6143 (comment) Additionally to deprecating, maybe we should update all MapboxNavigaitonProvider methods to call MapboxNavigationApp? WDYT?

We need to support MapboxNavigationProvider functionality for all the 2.x releases. Maybe there is another solution to maintain backwards compatibility, but I found a pretty straightforward solution awhile ago and haven't found a reason to update it. MapboxNavigationApp relies on MapboxNavigationProvider so that we can maintain backwards compatibility.

Any changes to MapboxNavigationProvider will risk a regression so I think it's best to leave it alone.

@kmadsen kmadsen force-pushed the km-remove-experimental-for-MapboxNavigationApp branch from 7b095a4 to 5b0e366 Compare August 11, 2022 21:02
@kmadsen kmadsen force-pushed the km-remove-experimental-for-MapboxNavigationApp branch from 5b0e366 to 0b6453c Compare August 11, 2022 21:03
@kmadsen kmadsen merged commit bf0f61f into main Aug 11, 2022
@kmadsen kmadsen deleted the km-remove-experimental-for-MapboxNavigationApp branch August 11, 2022 22:50
@@ -840,8 +841,9 @@ class MapboxNavigation @VisibleForTesting internal constructor(
* versionInfo: RoadGraphVersionInfo?
* ) {
* if (isUpdateAvailable) {
* mapboxNavigation.onDestroy()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This had some pretty bad consequences. Considering onDestroy will remove all registered listener

When using MapboxNavigationApp, this recreation can be done and listeners can be re-registered in MapboxNavigationObserver.onAttached

@VysotskiVadim
Copy link
Contributor

@kmadsen , do you suggest using MapboxNavigationApp in the examples?

@abhishek1508
Copy link
Contributor

@kmadsen , do you suggest using MapboxNavigationApp in the examples?

This is what we are aiming for. There would be a separate ticket that would change the instantiation of mapboxNavigation using MapboxNavigationApp in all the existing examples.

@kmadsen
Copy link
Contributor Author

kmadsen commented Aug 12, 2022

We are not entirely ready to migrate all examples (the release is still in alpha). We could migrate the examples now, but there are many helpful extensions we should consider that will makes migration simpler.

Here is a tracker for it though mapbox/mapbox-navigation-android-examples#128

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.

None yet

7 participants