googlemaps / react-native-navigation-sdk

Apache License 2.0
28 stars 5 forks source link

App freezing while navigating #87

Closed anielgroup closed 5 months ago

anielgroup commented 7 months ago

When the navigation works for a long time and the trip is longer than 15 minutes, the phone starts to heat up very much and freezes appear. When the screen just freezes and then prompts you to close the application

ArturoSalazarB16 commented 7 months ago

Hi @anielgroup, thanks for reporting. Is this on Android or iOS?

anielgroup commented 7 months ago

Android, we didn't test Ios yet

ArturoSalazarB16 commented 7 months ago

Thanks @anielgroup, we're taking a look FYI @caio1985

mtrecenio-navagis commented 7 months ago

Hi @anielgroup. I tried to reproduce the issue but wasn't able to encounter it. Attached is a screen recording link of Android Profiler where we can see the app CPU, memory and battery utilization. We can say that using the library, the app only utilizes below 25% of CPU, below 400MB of memory and "light" battery consumption while on navigation mode for about 15 mins as per testing.

See the video on this link: https://drive.google.com/file/d/16fX4HQnJ4gEg8EqwppTQZvfOlaluwegn/view?usp=sharing

Tested this using a real device - Samsung S22 running Android 14.

cc @ArturoSalazarB16 @zbillones-navagis

ArturoSalazarB16 commented 7 months ago

Hi @anielgroup, can you please share more details on the device you encounter the issue? (API level, Device name, Real versus Emulator device, etc). Also, are you able to reproduce this consistently?

Thanks, Arturo

anielgroup commented 7 months ago

Hi @ArturoSalazarB16

We use buildToolsVersion = "33.0.0" minSdkVersion = 23 compileSdkVersion = 33 targetSdkVersion = 33 appCompatVersion = "1.4.2" googlePlayServicesLocationVersion = "20.0.0" playServicesLocationVersion = "21.0.1" and implementation "com.google.android.libraries.navigation:navigation:5.2.3" navigation wi are testing on several devices including Samsung note 9, Samsung 21 ultra, Xiaomi Redmi 5 , Samsung S23

ArturoSalazarB16 commented 7 months ago

Thanks @anielgroup, in order to be able to diagnose the issue, can you please share:

anielgroup commented 7 months ago

Hey @ArturoSalazarB16 Yes this is appear on our app Attached sample of code GoogleMap.txt Video of our app

https://github.com/googlemaps/react-native-navigation-sdk/assets/121829153/804ef0ae-ab39-4b08-85dc-998415c9c5a0

OS level of the devices you're using to test. Are you able to reproduce consistently in all devices? we tested on the 2 android phone Samsung note 9 , Samsung S21 Ultra

Are you able to reproduce this on any routes? can you please share route details (origin, destination, other parameters they are using, ie. route token, etc) route token I could not find, we tested addresses: 1 Origin: תוצרת הארץ 1 פתח תקווה Destination: יצחק נבון 6 קריית אונו 2 Origin: תוצרת הארץ 1 פתח תקווה Waypoint: מגשימים 20 פתח תקווה Destination: השילוח 9 פתח תקווה 3 Origin: השילוח 9 פתח תקווה Destination: לחי 17 בני ברק

Dexail commented 7 months ago

Hi @ArturoSalazarB16 We created a copy of our project, but left only 1 page so that you could see the screen freeze. link on the github - https://github.com/Dexail/AniwayTestMobile

mtrecenio-navagis commented 7 months ago

Hi @Dexail . We were able to build the project in Android. However, we can only see a map with 3 markers in it, a top bar with check icon on the left and right arrow on the right which does nothing when you tap, and a bottomsheet showing the info of the journey. If this is the only screen you left for us to see the app freezing, on which part should we expect it to happen?

Dexail commented 7 months ago

Hi @ArturoSalazarB16 You need to start the navigation. Here's an example on the APK I created from the repository I shared with you earlier. If navigation doesn't start, try closing and reopening the application again.

https://github.com/googlemaps/react-native-navigation-sdk/assets/32589951/7baa4080-76dd-41be-a1d3-2368d8e5ebf3

anielgroup commented 7 months ago

Hi @ArturoSalazarB16, Did you reproduce the freezing issue ?

ArturoSalazarB16 commented 7 months ago

Hi @anielgroup @Dexail, thanks for the information.

@mtrecenio-navagis @zbillones-navagis - can you please try to get a repro based on the context above?

mtrecenio-navagis commented 7 months ago

Hi @anielgroup @Dexail , yes, we were able to reproduce the issue. We've checked your code in GoogleMap.tsx and found out that the culprit on the battery drain issue is the call for startUpdatingLocation() which then call for the RoadSnappedLocationProvider. Subscribing to this callback will consume more battery power than usual navigation which is documented here: https://developers.google.com/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/RoadSnappedLocationProvider

cc @ArturoSalazarB16 @zbillones-navagis

mtrecenio-navagis commented 7 months ago

@anielgroup @Dexail - We are reinvestigating this issue. On our test using the repo that you've shared here, 1/10 instance app freeze is encountered. Having the startUpdatingLocation() in the code should not be an issue. We are digging deeper into what really causing it as we can't replicate this issue using our SampleApp. Also, you may want to consider removing the vibration while on navigation by using navigationViewController.setAudioGuidanceType(AudioGuidance.VOICE_ALERTS_ONLY) to save battery, atleast.

More updates to come.

@ArturoSalazarB16 @zbillones-navagis

Dexail commented 7 months ago

@ArturoSalazarB16 @zbillones-navagis Hi Thank you, it really helped reduce the phone charger's consumption. Have you tried running navigation on iOS? It's just that on my iPhone 14 with the latest iOS version, navigation simply doesn't start.

P.S. If I try to set a new route, it doesn't build it on iOS. But if the route is based on already established points (for example, if I open the map on Android, it builds the route, then close and reopen it on iOS), then it builds on iOS.

mtrecenio-navagis commented 7 months ago

Hi @Dexail, we are looking into checking with iOS with your reported issue as well. We'll keep you posted. Thanks!

mtrecenio-navagis commented 7 months ago

Update on the iOS build @Dexail . I was able to build it on simulator running iOS 16.4. However, it does not get me into the map and got stuck on the animated splash screen with the aniway logo. I can hear the navigation voice alerts while on this splash screen. Screen recorded for reference.

https://github.com/googlemaps/react-native-navigation-sdk/assets/122425711/a136731a-69ac-410a-8315-4763c5280c56

mtrecenio-navagis commented 7 months ago

Also, were you able to check if the app still freezing on your end having the navigationViewController.setAudioGuidanceType(AudioGuidance.VOICE_ALERTS_ONLY) added to the code? Please let us know. Thanks!

jokerttu commented 5 months ago

Hi @anielgroup,

Are you still encountering this issue, or have you been able to identify the cause? If this is an issue with the SDK, we would appreciate more information on the issue or how it was fixed. This will help us in resolving this.

Thank you!

Dexail commented 5 months ago

Hi The issue of the screen freezing on the mobile phone was within the SDK itself. This occurred inside the plugin during distance calculation, causing it to crash and hang. The reason for this was the promise not being rejected when it failed, which resulted in the application freezing. We spent a lot of time, but we managed to fix the recalculation, and now there haven't been any instances of the application freezing.

In any case, thanks for trying to help us