osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.73k stars 1.03k forks source link

Sporadic error: "BRouter service is not available" #10148

Closed EssBee59 closed 4 years ago

EssBee59 commented 4 years ago

Dear all,

I am intensiv user of Osmand in combination with Brouter (12.000 km fastbike or MTB this year). Quit every thing works now fine with routing (thank again to vshcherb who helped resolving issues 7452/8534)

I want now to report a minor-sporadic problem when using the Brouter intensivly as myself (I am using Brouter because I need specific routing-profiles for fastbike and MTB)

Sometimes (2 or 3 times a week) , I get by starting a new routing in Osmand the error "BRouter service is not available". (To clear the error, I have to restart OSMAND...)

To analyse the problem, I added a special trace in my local Osmand installation (sources of osmand 3.9.0, compiled under windows) Result: Sporadically,the class "BRouterServiceConnection" is called with a "onServiceDisconnected". It looks like a "session inactivity time out", but it is some thing else, as it is sporadic and the "time out" varies (most of the times between from 15 to 90 minutes...) So, I could not get the real cause of the "onServiceDisconnected". RPC or Linux, no idee, I observed the issue on Android 8.1, Android 10 and on 3 different smartphones...

But, I tried a work-arround wich was successfull till now.

The change/work-arround: 1- "OsmandApplication.java" ==> BRouterServiceConnection bRouterServiceConnection; DECLARE as PUBLIC in order to be callable from routeprovider.java... 2- "RouteProvider.java" ==> Change as described in attachement "work-arround.txt"

kind regards Ess Bee

EssBee59 commented 4 years ago

work-arround.txt

EssBee59 commented 4 years ago

Hello,

Today I got a first explanation about the cause of the problem. "Logcat" says: 11-08 13:57:37.008 1648 5629 I ActivityManager: Killing 8944:btools.routingapp:brouter_service/u0a307 (adj 930): empty #17 11-08 13:57:37.013 1648 2129 I chatty : uid=1000(system) MiuiNetworkPoli expire 5 lines 11-08 13:57:37.051 678 678 I Zygote : Process 8944 exited due to signal 9 (Killed)

This cause is possibly known / problem looks similar to that issue https://stackoverflow.com/questions/23243102/activitymanager-kills-running-process-of-system-app https://stackoverflow.com/questions/6645193/foreground-service-being-killed-by-android

but a simple solution is to try a reconnect as in my work-arround

EssBee59 commented 4 years ago

I forgot above to document the real / deep cause for the process killing: It seems initiated by the batterie survey...

11-08 13:57:36.560 2379 2379 D KeyguardUpdateMonitor: received broadcast android.intent.action.BATTERY_CHANGED 11-08 13:57:36.560 3675 3675 D NfcService: Received android.intent.action.BATTERY_CHANGED 11-08 13:57:36.562 4535 4535 I BatteryInfoReceiver: ACTION_BATTERY_CHANGED 11-08 13:57:36.563 5366 5581 D PowerCheckerService: onBatteryChanged, mBatteryLevel = 87, status = 3, level = 87, plug = 0, scale = 100 11-08 13:57:36.563 5366 5426 D PowerKeeper.FrozenApp: onBatteryChanged plug=false mBatteryPlugged=0

A very complex topic! I think, a "reconnect" in Osmand (as tested in my work-arround) is a simple and helpfull solution

vshcherb commented 4 years ago

I would love in the future to change connectivity and have B-Router installed as a plugin and work similar like OsmAnd Tracker works. So I don't know what would be easy fix for this problem...

EssBee59 commented 4 years ago

Hello vshcherb,

Thank for your response and information about the planed change in the architecture! May I describe a new feature which would be very nice for intensiv users?

-The curent interface osmand-brouter is complex: installation, setting and configuration are "not easy", it is very difficult to switch from a brouter-profile to another...

Thank for your work regards

vshcherb commented 4 years ago

I need to contact BRouter developer first, some code will need to work through OsmAnd API.

EssBee59 commented 4 years ago

I had contact with Arndt some months ago. He gave me some tipps to developpe a prototype with an extended interface---

I made an extend in the class "BRouterService.java" of brouter-app to support as new parameter the name of the profile to be used! After a small corresponding extention in Osmand I enjoy this feature on my phone now!