Async native methods#4881
Conversation
LukasPaczos
left a comment
There was a problem hiding this comment.
With the proposal, we can run into a situation like this:
2021-09-23 13:34:36.241 30154-30154/com.mapbox.navigation.examples E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mapbox.navigation.examples, PID: 30154
java.lang.IllegalStateException: Next route leg started while an active guidance session is not running.
Actual active SKU: Nav2SesFDTrip
at com.mapbox.navigation.core.accounts.BillingController$arrivalObserver$1.onNextRouteLegStart(BillingController.kt:237)
at com.mapbox.navigation.core.arrival.ArrivalProgressObserver$navigateNextRouteLeg$1.invokeSuspend(ArrivalProgressObserver.kt:65)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I can reproduce this by doing below once in active guidance:
mapboxNavigation.navigateNextRouteLeg {}
mapboxNavigation.setRoutes(emptyList())
This is because setRoutes synchronously resets the trip session state to free drive, and only then the async leg update returns.
It looks like we have 2 options:
- Do not observe arrival observer when session is not active guidance.
- Do not deliver arrival callbacks when the state is not valid anymore.
I feel like we need to do the latter - after completing the communication with NN, we should verify that the state is still valid and only then notify developers. Otherwise, there could be many more bugs with this approach, for example we could be delivering leg switch calls after a session is stopped, etc.
67437f3 to
9150513
Compare
|
@LukasPaczos I've rebased and force-pushed the branch. |
9150513 to
88be8e1
Compare
88be8e1 to
785360c
Compare
785360c to
3e02d17
Compare
|
@Guardiola31337 @Zayankovsky @LukasPaczos ready to the next round |
3e02d17 to
fb4acc7
Compare
|
This is probably the same crash we were seeing in #4726 which will be solved by #4919 |
fb4acc7 to
d112202
Compare
36d4480 to
778cea6
Compare
778cea6 to
d444f72
Compare
Description
NavNative async methods integration.
Changelog
Screenshots or Gifs