organicmaps / organicmaps

🍃 Organic Maps is a free Android & iOS offline maps app for travelers, tourists, hikers, and cyclists. It uses crowd-sourced OpenStreetMap data and is developed with love by MapsWithMe (MapsMe) founders and our community. No ads, no tracking, no data collection, no crapware. Please donate to support the development!
https://organicmaps.app
Apache License 2.0
9.49k stars 912 forks source link

Android Auto Stability #6716

Open ZippyGerbil opened 9 months ago

ZippyGerbil commented 9 months ago

Describe the issue Have experienced instability with initial Android Auto beta (2023.11.22-3). Incidentally, my first trip (and some others) worked really well, and a massive thank you for the work on this.

Unfortunately I'm not sure whether these issues are linked or not. I've had mixed success in determining the exact steps to reproduce as they've happened during real-world use, often needing to hurriedly restart/switch to Google Maps, so have listed in a single issue for now.

I don't often have access to a car with Android Auto, so thought I'd better document what I've come across so far.

1 - Switching between apps

When switching from Organic Maps on Android Auto to another app on AA (e.g. Spotify, phone), navigation does not recover well.

It seems to not recover if the 'back' softkey is pressed in the other application, simply switching between apps without performing an action in them didn't seem to cause an issue.

On one occasion restoring Organic Maps seemed to result in the app restarting after an 'Android Auto is not responding' screen, and launching back into a route plan screen.

On another in the same switch-app scenario, the app itself recovered but with route guidance frozen - though position indicator continued to track

PXL_20231127_210550603

2 - Map stops rendering

On a couple of occasions when near a destination, and after a few minutes pause (possible engine cycle off/on), OM stopped rendering the map and was unable to recover.

Managed to capture the same behaviour in a slightly different scenario, where I think I'd tried to cancel guidance / choose different destination. PXL_20231127_095017917 PXL_20231127_095054527

3 - Phone screen vs car screen sync

On trying to open Organic Maps from Android Auto, received the message 'You are now using Organic Maps on the phone screen'.

Seemed to fall out of sync with mobile app. On some occasions I'd have the alternative message on the phone, saying I was using Organic Maps on Android Auto. Tapping the screen had no effect.

Again, experienced this a couple of times but unclear reasoning. Closing mobile app didn't seem to help, only experienced being able to recover from this state when I was able to turn the car off and on.

Fixed in #7242 Updated by @AndrewShkrob

System information:

rtsisyk commented 9 months ago

Thanks for your detailed feedback! Rendering and switching to phone and back were two primary challenges we had all the time. We definitely need more testing in the field on real devices. What car brand do you drive?

AndrewShkrob commented 9 months ago

I believe that problems 2 and 3 are mainly caused by using Vulkan (problem 3 is 100% because of it). @ZippyGerbil, it would be great if you could switch to OpenGL and check again if these bugs are still present.

How to switch to OpenGL:

The first problem requires deeper investigation. I can't say for sure what's causing it at the moment.

ZippyGerbil commented 9 months ago

@AndrewShkrob Thanks. I was about to say Vulkan seems to be the cause of 1 & 2. I didn't get to test as much today, but no similar issues were apparent after switching to OpenGL.

The logs tell a slightly different story though. I captured a couple of crashes before switching to OpenGL:

11-28 07:05:36.577 E/AndroidRuntime( 7918): FATAL EXCEPTION: main 11-28 07:05:36.577 E/AndroidRuntime( 7918): Process: app.organicmaps, PID: 7918 11-28 07:05:36.577 E/AndroidRuntime( 7918): java.lang.RuntimeException: Unable to start service app.organicmaps.routing.NavigationService@294d477 with Intent { cmp=app.organicmaps/.routing.NavigationService }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{f207b3f 7918:app.organicmaps/u0a269} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4839) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Handler.dispatchMessage(Handler.java:106) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Looper.loopOnce(Looper.java:205) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Looper.loop(Looper.java:294) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.ActivityThread.main(ActivityThread.java:8177) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at java.lang.reflect.Method.invoke(Native Method) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 11-28 07:05:36.577 E/AndroidRuntime( 7918): Caused by: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{f207b3f 7918:app.organicmaps/u0a269} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Parcel.createExceptionOrNull(Parcel.java:3057) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Parcel.createException(Parcel.java:3041) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Parcel.readException(Parcel.java:3024) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.os.Parcel.readException(Parcel.java:2966) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.Service.startForeground(Service.java:775) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at app.organicmaps.routing.NavigationService.onStartCommand(NavigationService.java:214) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4821) 11-28 07:05:36.577 E/AndroidRuntime( 7918): ... 9 more 11-28 07:05:36.577 E/AndroidRuntime( 7918): Caused by: android.os.RemoteException: Remote stack trace: 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2611) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2322) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1679) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13281) 11-28 07:05:36.577 E/AndroidRuntime( 7918): at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3385)

Looking through, I see a couple of identical crashes after the switch - the difference being that I didn't feel like I experienced a crash. I guess it just recovered somehow and I didn't spot it.

Obviously I have granted OM fine location permission, so I guess in some circumstances Android is no longer considering OM to be in the foreground?

ZippyGerbil commented 9 months ago

Incidentally, this was on a new Nissan - not mine though, I have very adhoc access to cars so might be a while before I can retest.

rtsisyk commented 9 months ago

E/AndroidRuntime( 7918): Caused by: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{f207b3f 7918:app.organicmaps/u0a269} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION]

I thought that we had fixed the problem a month ago: https://github.com/organicmaps/organicmaps/commit/d4ccedf59bcd88168f9478559a5e432d964bd733

Please check that the app in the phone has location permission granted?

biodranik commented 9 months ago

@rtsisyk please check how OM behaves with disabled permissions and create an issue if necessary. A clear dialog is needed that permissions should be granted to avoid confusion.

ZippyGerbil commented 9 months ago

Please check that the app in the phone has location permission granted?

Screenshot_20231129-103710 (1)

rtsisyk commented 9 months ago

ok, I need to get a Google device with Android 14.. Or maybe I can try to install Android Auto via root to CalyxOS.

amirshahab89 commented 9 months ago

I have similar issues presently while using the latest Organic Maps (Samsung A50, Android 11) on a Kia Sportage 2017 vehicle. Latest software installed from update.kia.com.