mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
621 stars 319 forks source link

NAVAND-2991 - Optimized TextToSpeech usage #7833

Closed tomaszrybakiewicz closed 3 months ago

tomaszrybakiewicz commented 3 months ago

Issue

NAVAND-2991

Description

Backporting v3 optimization https://github.com/mapbox/navigation/pull/5638

NavSDK 2.0 traces captured from "examples > Voice Example" activity running on Android Emulator.

Call Baseline Optimized
TextToSpeechProvider.getTextToSpeech(...) MAIN
21ms
DEFAULT
30ms
VoiceInstructionsTextPlayer.initializeWithLanguage(...) MAIN
207ms
DEFAULT
508ms
textToSpeech.speak(...) MAIN
25ms
1ms
DEFAULT
15ms
1ms

I've moved both initializeWithLanguage(...) and textToSpeech.speak(...) calls to the background thread to optimize this. Additionally, I've updated the "examples > Voice Example" activity to initialize MapboxVoiceInstructionsPlayer off the main thread. The optimized execution time slightly increased due to lesser background thread prioritization.

navsdk-cpu-perfetto.baseline.trace.zip navsdk-cpu-perfetto.optimized.trace.zip

github-actions[bot] commented 3 months ago
Changelog #### Features #### Bug fixes and improvements - Fixed UI jank caused by on-device TextToSpeech player. `[#7833](https://github.com/mapbox/mapbox-navigation-android/pull/7833)` #### Known issues :warning: #### Other changes
Android Auto Changelog #### Features #### Bug fixes and improvements - The app is now considered as the one in active navigation only when an active route is set to `MapboxNavigation`. Previously it was always considered active. `[#7366](https://github.com/mapbox/mapbox-navigation-android/pull/7366)` - When Android Auto host tells the app to stop active navigation because another app starts navigating, now SDK will enter FreeDrive mode instead of stopping trip session completely. `[#7366](https://github.com/mapbox/mapbox-navigation-android/pull/7366)`
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.17%. Comparing base (ef828e6) to head (1901e79).

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #7833   +/-   ##
=========================================
  Coverage     74.16%   74.17%           
+ Complexity     6265     6262    -3     
=========================================
  Files           856      856           
  Lines         33779    33789   +10     
  Branches       4023     4023           
=========================================
+ Hits          25053    25062    +9     
- Misses         7168     7170    +2     
+ Partials       1558     1557    -1     
Files Coverage Δ
...gation/ui/voice/api/VoiceInstructionsTextPlayer.kt 82.02% <88.88%> (+1.00%) :arrow_up: