Skip to content

Async native methods#4881

Merged
korshaknn merged 1 commit into
mainfrom
knn-async-set-route
Oct 1, 2021
Merged

Async native methods#4881
korshaknn merged 1 commit into
mainfrom
knn-async-set-route

Conversation

@korshaknn

@korshaknn korshaknn commented Sep 22, 2021

Copy link
Copy Markdown
Contributor

Description

NavNative async methods integration.

Changelog

<changelog>
Added callback to navigation::navigateNextRouteLeg method
Added callback to navigation::updateSensorEvent method
</changelog>

Screenshots or Gifs

@korshaknn korshaknn added the ⚠️ DO NOT MERGE PR should not be merged! label Sep 22, 2021
@korshaknn korshaknn self-assigned this Sep 22, 2021

@LukasPaczos LukasPaczos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@korshaknn

Copy link
Copy Markdown
Contributor Author

@LukasPaczos I've rebased and force-pushed the branch.
btw, MapboxNativeNavigatorImpl.getCurrentBannerInstruction() is suspend now, so we have a coroutine inside
onStatus callback.
We might need to add one more updateRouteProgress: Joband cancel it on a new status

@korshaknn
korshaknn marked this pull request as ready for review September 28, 2021 10:49
@korshaknn
korshaknn requested a review from a team as a code owner September 28, 2021 10:49
@korshaknn

Copy link
Copy Markdown
Contributor Author

@Guardiola31337 @Zayankovsky @LukasPaczos ready to the next round

@korshaknn korshaknn added backwards incompatible Requires a SEMVER major version change. and removed ⚠️ DO NOT MERGE PR should not be merged! labels Sep 29, 2021
@Guardiola31337

Copy link
Copy Markdown
Contributor

ui-robo-tests are 💥

09-29 08:17:35.361: A/DEBUG(2402): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-29 08:17:35.361: A/DEBUG(2402): Build fingerprint: 'google/flame/flame:11/RP1A.201005.004/6782484:user/release-keys'
09-29 08:17:35.361: A/DEBUG(2402): Revision: 'MP1.0'
09-29 08:17:35.361: A/DEBUG(2402): ABI: 'arm64'
09-29 08:17:35.362: A/DEBUG(2402): Timestamp: 2021-09-29 08:17:35-0700
09-29 08:17:35.362: A/DEBUG(2402): pid: 22617, tid: 23017, name: Worker 4  >>> com.mapbox.navigation.examples <<<
09-29 08:17:35.362: A/DEBUG(2402): uid: 10250
09-29 08:17:35.362: A/DEBUG(2402): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-29 08:17:35.362: A/DEBUG(2402): Abort message: 'terminating with uncaught exception of type network::uri_syntax_error'
09-29 08:17:35.362: A/DEBUG(2402):     x0  0000000000000000  x1  00000000000059e9  x2  0000000000000006  x3  000000764b602ae0
09-29 08:17:35.362: A/DEBUG(2402):     x4  fefeff716e717164  x5  fefeff716e717164  x6  fefeff716e717164  x7  7f7f7f7f7f7f7f7f
09-29 08:17:35.362: A/DEBUG(2402):     x8  00000000000000f0  x9  d49162a4294dbc1b  x10 0000000000000000  x11 ffffffc0fffffbdf
09-29 08:17:35.362: A/DEBUG(2402):     x12 0000000000000001  x13 00000002605eeda2  x14 00059b1b7cf2bd26  x15 00000000000476f0
09-29 08:17:35.362: A/DEBUG(2402):     x16 000000796a614c80  x17 000000796a5f63b0  x18 000000764af8e000  x19 0000000000005859
09-29 08:17:35.362: A/DEBUG(2402):     x20 00000000000059e9  x21 00000000ffffffff  x22 ffffff80ffffffc8  x23 000000764b602d30
09-29 08:17:35.362: A/DEBUG(2402):     x24 000000764b602c10  x25 000000764b602c50  x26 b40000775720b188  x27 000000764b603b98
09-29 08:17:35.362: A/DEBUG(2402):     x28 000000764b50b000  x29 000000764b602b60
09-29 08:17:35.362: A/DEBUG(2402):     lr  000000796a5a9e20  sp  000000764b602ac0  pc  000000796a5a9e4c  pst 0000000000000000
09-29 08:17:35.367: A/DEBUG(2402): backtrace:
09-29 08:17:35.367: A/DEBUG(2402):       #00 pc 000000000004de4c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 03452a4a418e14ff93948f26561eace6)
09-29 08:17:35.367: A/DEBUG(2402):       #01 pc 000000000009ce88  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
09-29 08:17:35.367: A/DEBUG(2402):       #02 pc 000000000009d094  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
09-29 08:17:35.367: A/DEBUG(2402):       #03 pc 00000000000aead0  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
09-29 08:17:35.367: A/DEBUG(2402):       #04 pc 00000000000ae0fc  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
09-29 08:17:35.367: A/DEBUG(2402):       #05 pc 00000000000ae058  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libc++_shared.so (__cxa_throw+112) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
09-29 08:17:35.367: A/DEBUG(2402):       #06 pc 0000000000b75668  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libnavigator-android.so (BuildId: 21b13c79e4bda956)
09-29 08:17:35.367: A/DEBUG(2402):       #07 pc 0000000000b75314  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libnavigator-android.so (BuildId: 21b13c79e4bda956)
09-29 08:17:35.367: A/DEBUG(2402):       #08 pc 0000000000b806c4  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libnavigator-android.so (BuildId: 21b13c79e4bda956)
09-29 08:17:35.367: A/DEBUG(2402):       #09 pc 0000000000b5a954  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libnavigator-android.so (BuildId: 21b13c79e4bda956)
09-29 08:17:35.367: A/DEBUG(2402):       #10 pc 00000000000ce1a0  /data/app/~~6VSl47jwHsVrtnxCWL-Enw==/com.mapbox.navigation.examples-DRZuZEoGmYjNuEDAzSi34Q==/lib/arm64/libmapbox-common.so (BuildId: 84fa302f37b8bf91)
09-29 08:17:35.367: A/DEBUG(2402):       #11 pc 00000000000af888  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 03452a4a418e14ff93948f26561eace6)
09-29 08:17:35.367: A/DEBUG(2402):       #12 pc 000000000004fe08  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 03452a4a418e14ff93948f26561eace6)

This is probably the same crash we were seeing in #4726 which will be solved by #4919

cc @mskurydin @SiarheiFedartsou

@Guardiola31337 Guardiola31337 added the needs backporting Requires cherry-picking to a currently running release branch label Sep 30, 2021
@korshaknn
korshaknn force-pushed the knn-async-set-route branch from 778cea6 to d444f72 Compare October 1, 2021 13:30
@korshaknn
korshaknn merged commit f9bb62e into main Oct 1, 2021
@korshaknn
korshaknn deleted the knn-async-set-route branch October 1, 2021 14:34
@Guardiola31337 Guardiola31337 removed the needs backporting Requires cherry-picking to a currently running release branch label Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards incompatible Requires a SEMVER major version change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants