osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.6k stars 1.01k forks source link

Track recording doesn't record in the background (Android 8, EMUI 8) #5632

Closed vshcherb closed 5 years ago

vshcherb commented 6 years ago

I noticed a bad bug in current release: during navigation Osmand very frequently shut down when running in background. I have installed Osmand+ 3.0.4 on Huawei P10 with Android 8.0.

The issue is that during navigation after some time Osmand close instead than keep running in background and consequently the navigation stops. I do not think it is related with strict battery optimization policy of Huawei phones, because it never happen before.

I started to notice this only with last version.

sonora commented 6 years ago

Yes, agree, I guess we can cross-link this to issues like #5587?

MarkusTV commented 6 years ago

I don't know if it can be useful for investigation, anyway I noticed that when I reopen Osmand after the crash in background it shows a 5 seconds countdown message asking if continue or not the interrupted route navigation. It means that Osmand realizes that something happen and try to resume.

sonora commented 6 years ago

Yes, that is a standard feature we have if OsmAnd was closed while a navigation was ongoing. It is a result of the issue, not the cause of it.

MarkusTV commented 6 years ago

Ok got it, thank you. My question is if Osmand crashes itself or it is forced closed by o.s (Android or Huawei EMUI maybe for battery optimization purposes). I do not think so because the issue is new, appeared in this last version for first time only.

Marco

Da: Hardy notifications@github.com Inviato: sabato 7 luglio 2018 22:18 A: osmandapp/Osmand Osmand@noreply.github.com Cc: MarkusTV marco.brun@outlook.com; Manual manual@noreply.github.com Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

Yes, that is a standard feature we have if OsmAnd was closed while a navigation was ongoing. It is a result of the issue, not the cause of it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-403240542, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKKVO5oFjU3t2TIyH2mnVWvtllwe2ks5uEReJgaJpZM4VCUQ4.

sonora commented 6 years ago

Thar's interesting, so far I had attributed it to OS behavior, but you are saying it could be an OsmAnd regression?

MarkusTV commented 6 years ago

No idea, I cannot say that, I see that Osmand closes but I don't know if closes itself or it is killed by the OS.

Marco


Da: Hardy notifications@github.com Inviato: domenica 8 luglio 2018 10:01 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

Thar's interesting, so far I had attributed it to OS behavior, but you are saying it could be an OsmAnd regression?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-403270297, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKNS7juO11hl_bzIhfsHBX66mIrZLks5uEbxcgaJpZM4VCUQ4.

sonora commented 6 years ago

I suppose excluding OsmAnd from any app optimization does not fix it? http://www.androidbeat.com/2017/03/how-to-stop-android-apps-killed-marshmallow-nougat/

MarkusTV commented 6 years ago

Unfortunately not. I tried many other settings (ignore battery optimization, keep running in background, keep running under lock screen, whitelist, put in protected app list...) but no changes. I cannot say for sure but I suspect of Osmand because it never happen in previous versions, it is a new issue, much newer than Marshmallow and its doze battery management.

Marco


Da: Hardy notifications@github.com Inviato: domenica 8 luglio 2018 15:23 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

I suppose excluding OsmAnd from any app optimization does not fix it? http://www.androidbeat.com/2017/03/how-to-stop-android-apps-killed-marshmallow-nougat/

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-403287592, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKLkNk6YP0l3Ecno3TgA3lXlrmUrzks5uEgfMgaJpZM4VCUQ4.

sonora commented 6 years ago

Can you reliably pinpoint with which version it started?

MarkusTV commented 6 years ago

I cannot say for sure but it is recent, maybe in current 3.0.4 or maximum in the previous one, but it is not older than this.

Marco


Da: Hardy notifications@github.com Inviato: domenica 8 luglio 2018 23:32 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

Can you reliably pinpoint with which version it started?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-403318838, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKEKP9ONzEskkh_FpVdxtgQY_bu7Lks5uEnpwgaJpZM4VCUQ4.

Idrive-walking commented 6 years ago

Hi, I'm a very old user of Osmand+ (from 2012). Me too I've noticed the "supposed bug" of Osmand but I think it is also a problem in Oreo 8.0 because I tried many others applications to navigate along tracks or to record tracks while walking and the only one that is not closing while in background and screen off is (on my phone, of course) RunKeeper. I tried Orux Maps, Wikiloc, ViewRanger, Locusmap and all of them are closed by system after 5-7 minutes. I hope this can help

MarkusTV commented 6 years ago

Hi, it is probably a particular combination of Operating System (Android 8.0), and Phone user interface (I use Huawei EMUI). But you are right, some apps are affected and some not. I hope that Osmand will be able to stay with best ones.

Da: Idrive-walking notifications@github.com Inviato: venerdì 20 luglio 2018 13:34 A: osmandapp/Osmand Osmand@noreply.github.com Cc: MarkusTV marco.brun@outlook.com; Manual manual@noreply.github.com Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

Hi, I'm a very old user of Osmand+ (from 2012). Me too I've noticed the "supposed bug" of Osmand but I think it is also a problem in Oreo 8.0 because I tried many others applications to navigate along tracks or to record tracks while walking and the only one that is not closing while in background and screen off is (on my phone, of course) RunKeeper. I tried Orux Maps, Wikiloc, ViewRanger, Locusmap and all of them are closed by system after 5-7 minutes. I hope this can help

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-406574575, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKEup7VOlM5pnWqvm_mJRd4nAKxT1ks5uIcA6gaJpZM4VCUQ4.

Idrive-walking commented 6 years ago

Hi, Marco (italiano ... anch'io), I forgot to say I'm using a Huawei Honor 8pro and Emui 8.0.0.366

MarkusTV commented 6 years ago

Ciao! Yes, the combination between Android 8.0 and Huawei EMUI 8.0 is a nightmare. But as I said, some apps are able to avoid these problems, hope that Osmand will find a fix too.

Marco

Da: Idrive-walking notifications@github.com Inviato: venerdì 20 luglio 2018 15:43 A: osmandapp/Osmand Osmand@noreply.github.com Cc: MarkusTV marco.brun@outlook.com; Manual manual@noreply.github.com Oggetto: Re: [osmandapp/Osmand] OsmAnd very frequently shut down when running in background. (#5632)

Hi, Marco (italiano ... anch'io), I forgot to say I'm using a Huawei Honor 8pro and Emui 8.0.0.366

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-406604420, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKLsw8BPtS4UZPnaw5EDg0fIFkao4ks5uId5ngaJpZM4VCUQ4.

Idrive-walking commented 6 years ago

Hi, today I've made a trip with my old Samsung Note 3, Android 5.0 and Osmand+ 3.0.4 following a GPX track. Everything worked fine and voice guidance was up all the time. Hope this helps

vshcherb commented 6 years ago

Indeed we are expecting that some applications are using different "target-sdk" i.e. they target different Android version which triggers different execution path in Android 8.0.

The biggest change in Android 8.0 if the process running in the background, it must have a notification otherwise it is going to be killed. With last release we targetted Android 8.0 & implemented that requirement. There are still lots of combinations in the world, apps target Android 4.* or Android 5... and run on Android 8.0, in that case it is not really clear how OS will operate.

Unfortunately we can't lower target Android SDK cause Google Play forbids from August to lower SDK than 8.0 and from November none of the application could be published with lower target SDK than 8.0.

Currently, we are investigating if we forget to enable something or specify a certain flag. If we don't find and we don't manage to reproduce on devices we have, it will confirm a bug in Android 8.0 OS of a specific vendor. What would be really annoying that we target Android 8.0 and have most of the issues on Android 8.0 and not on Android 7 for example.

Idrive-walking commented 6 years ago

Thanks for the explaination. I have also a strange idea (near science fiction): could it possible that inside Android there is a "white list" of apps that the system don't kills? Or else is the issue connected to the way of tracking Gps? Two apps I use that are born for sport and training (Runkeeper and Mapmyhike) continue working in background other, born for navigation (on-line or off-line), are killed by android (OruxMaps, LocusMap, Osmamd, Wikilock, Viewranger etc. but not Google Map). Does this make any sense? Guido

Il dom 22 lug 2018, 14:00 vshcherb notifications@github.com ha scritto:

Indeed we are expecting that some applications are using different "target-sdk" i.e. they target different Android version which triggers different execution path in Android 8.0.

The biggest change in Android 8.0 if the process running in the background, it must have a notification otherwise it is going to be killed. With last release we targetted Android 8.0 & implemented that requirement. There are still lots of combinations in the world, apps target Android 4.* or Android 5... and run on Android 8.0, in that case it is not really clear how OS will operate.

Unfortunately we can't lower target Android SDK cause Google Play forbids from August to lower SDK than 8.0 and from November none of the application could be published with lower target SDK than 8.0.

Currently, we are investigating if we forget to enable something or specify a certain flag. If we don't find and we don't manage to reproduce on devices we have, it will confirm a bug in Android 8.0 OS of a specific vendor. What would be really annoying that we target Android 8.0 and have most of the issues on Android 8.0 and not on Android 7 for example.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osmandapp/Osmand/issues/5632#issuecomment-406860578, or mute the thread https://github.com/notifications/unsubscribe-auth/Anjbk3VSbcdEP4xPRPlVA9JBfc5BNHUjks5uJGl4gaJpZM4VCUQ4 .

vshcherb commented 6 years ago

So far tested on OnePlus3T, Samsung S8, Xiaomi Mi A1 with Android 8. And track recording works fine in the background.

stacybrock commented 6 years ago

I recently upgraded my phone to Android 8 (Oreo) and am seeing this issue when trip recording is turned on and the phone is on battery power.

Please let me know if you need more information. I'm going to try recording another trip tonight so I can provide an example GPX file.

MarkusTV commented 6 years ago

Hi, I never tried if the issue happens during track recording, probably it does. For me it happen always during navigation after 5-6 minutes in lock screen.

Marco


Da: vshcherb notifications@github.com Inviato: martedì 24 luglio 2018 20:27 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background on Android 8 (#5632)

So far tested on OnePlus3T, Samsung S8, Xiaomi Mi A1 with Android 8. And track recording works fine in the background.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-407506198, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKN_Ug89jmNPQ478jvB5edgaNLVS_ks5uJ2cQgaJpZM4VCUQ4.

matthewblain commented 6 years ago

What does this mean:

So far tested on OnePlus3T, Samsung S8, Xiaomi Mi A1 with Android 8. And track recording works fine in the background.

Is that with a new version of Osmand? As I noted in issue #5587 it definitely stops working under some circumstances on my Moto X4. I have not tried navigation in the background (the original issue in this bug) as I almost never do that.).

MarkusTV commented 6 years ago

Hi, I found a workaround for this, not nice but it works. Android kills Osmand when in background after 5-6 minutes. Ok then I set repeat vocal announcements every 3 minutes and turn on the screen on vocal announcements. So at least every 3 minutes the Android countdown is reset and restart from zero. I repeat: not a nice solution but it works. Maybe Osmand should be able to "simulate" this situation without necessarily turn on the screen.

Marco


Da: matthewblain notifications@github.com Inviato: lunedì 30 luglio 2018 03:22 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background on Android 8 (#5632)

What does this mean:

So far tested on OnePlus3T, Samsung S8, Xiaomi Mi A1 with Android 8. And track recording works fine in the background.

Is that with a new version of Osmand? As I noted in issue #5587https://github.com/osmandapp/Osmand/issues/5587 it definitely stops working under some circumstances on my Moto X4. I have not tried navigation in the background (the original issue in this bug) as I almost never do that.).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-408721719, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKL8sWOhGFjDL6I5B5YjrfO5zHwgMks5uLl_vgaJpZM4VCUQ4.

Idrive-walking commented 6 years ago

hi Marco, I've had the same idea but, for me did not worked. But I have'nt tried switching on the screen.(me idiot) 😩 Guido

Il gio 2 ago 2018, 17:55 MarkusTV notifications@github.com ha scritto:

MarkusTV commented 6 years ago

Yes, the vocal announcement is not enough to convince Android to do not kill the process, but the screen switch on works. Of course it is more an experiment than a solution, having redundant vocal announcements and unnecessary screen turning on is annoying and not pleasant for the battery.

Marco

lehenry commented 6 years ago

Hello,

I have seen the issue on a Huawei P20 Pro, Android 8.1, EMUI 8.1.

After disabling all battery optimisations settings for OSMAnd, the issue persisted.

The notification shows when the tracking is enabled. When the OSM runs on the background, and the screen is switched off, then on again, 5+ second later, the notification has disappeared. If I open again the application, the notification shows up again, but the tracking in between didn't work.

My guess is that a clean-up of notifications cause the tracking to stop/pause.

MRigal commented 6 years ago

I can confirm the behaviour on my Honor 10 with Android 8 EMUI 8

MarkusTV commented 6 years ago

I do not know if Osmand can do something, maybe it is over their possibilities, but the issue is very serious, unbelievable that Huawei, Honor, ignore it. Osmand, AlpineQuest, Orux, Viewranger, maybe almost all similar apps (except Google Maps of course) are killed after about 5 minutes even setting any possible protection (allow running in background, ignore battery optimization, whitelist in protected apps, etc.). All these settings are simply ignored. This of course makes Osmand (as well as all other apps) almost useless: impossible to use navigation, impossible to record a track. I heard that the issue is much wider, it does not concerns only navigation apps but also other apps which typically need to remain active in background, like music players, etc. For example I read that VLC banned Huawei, they made impossible to install VLC from PalyStore in Huawei devices. I am afraid that we are in the middle of a battle bigger than Osmand.

Marco

bsidhom commented 6 years ago

I'm seeing this issue as well with OsmAnd 3.1.5. I'm using a Pixel 2 XL on Android 9. I've had "battery optimization" disabled for OsmAnd ever since the doze feature was introduced. I'm able to record GPX logs for a few hours before it cuts out abruptly. I only notice that it has stopped recording when I reopen the app to check on it.

MarkusTV commented 6 years ago

Bad news, it means it is not only Huawei and no hope to see this fixed in the future. It means it is not a bug but a strategy to force users to do not use certain apps.

Marco


Da: Ben Sidhom notifications@github.com Inviato: martedì 4 settembre 2018 07:39 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background (Android 8, EMUI 8) (#5632)

I'm seeing this issue as well with OsmAnd 3.1.5. I'm using a Pixel 2 XL on Android 9. I've had "battery optimization" disabled for OsmAnd ever since the doze feature was introduced. I'm able to record GPX logs for a few hours before it cuts out abruptly. I only notice that it has stopped recording when I reopen the app to check on it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fosmandapp%2FOsmand%2Fissues%2F5632%23issuecomment-418246962&data=02%7C01%7C%7C5e363cf4d64b4b34d99d08d61228d2ea%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716363870106297&sdata=H%2BHIQ0gvLYzwZbRmQyrL8TQlkBAkyZHIOI0i3PxXEBY%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAm7zKBPUOfMOXbmsQaTQaqpwp2jipTA3ks5uXhIigaJpZM4VCUQ4&data=02%7C01%7C%7C5e363cf4d64b4b34d99d08d61228d2ea%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716363870106297&sdata=g%2FytzHacvYSGWqDtBj%2BGhLl7qTbWPWTPaCE%2Fy3QO3pU%3D&reserved=0.

Idrive-walking commented 6 years ago

Hi Marco, I've installed VLC on my Honor 8pro and Android 8.0.0 without any problem, so, again, I think that the issue is on some settings of some apps working in background with GPS.

Il giorno 04 set 2018, alle ore 07:45, MarkusTV notifications@github.com ha scritto:

Bad news, it means it is not only Huawei and no hope to see this fixed in the future. It means it is not a bug but a strategy to force users to do not use certain apps.

Marco


Da: Ben Sidhom notifications@github.com Inviato: martedì 4 settembre 2018 07:39 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background (Android 8, EMUI 8) (#5632)

I'm seeing this issue as well with OsmAnd 3.1.5. I'm using a Pixel 2 XL on Android 9. I've had "battery optimization" disabled for OsmAnd ever since the doze feature was introduced. I'm able to record GPX logs for a few hours before it cuts out abruptly. I only notice that it has stopped recording when I reopen the app to check on it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fosmandapp%2FOsmand%2Fissues%2F5632%23issuecomment-418246962&data=02%7C01%7C%7C5e363cf4d64b4b34d99d08d61228d2ea%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716363870106297&sdata=H%2BHIQ0gvLYzwZbRmQyrL8TQlkBAkyZHIOI0i3PxXEBY%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAm7zKBPUOfMOXbmsQaTQaqpwp2jipTA3ks5uXhIigaJpZM4VCUQ4&data=02%7C01%7C%7C5e363cf4d64b4b34d99d08d61228d2ea%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636716363870106297&sdata=g%2FytzHacvYSGWqDtBj%2BGhLl7qTbWPWTPaCE%2Fy3QO3pU%3D&reserved=0. — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osmandapp/Osmand/issues/5632#issuecomment-418247896, or mute the thread https://github.com/notifications/unsubscribe-auth/Anjbk2R3cCj2Wm6K10rmQc_XNZaeUlyVks5uXhOMgaJpZM4VCUQ4.

MarkusTV commented 6 years ago

Hi, I did not try VLC, I just reported some news I heard, if VLC works fine much better. If it is only an issue of some apps working in background with GPS I am happy, in this case I hope it will be fixed soon.

Marco

sonora commented 5 years ago

The Samsung XCover4 has received its update from Android 7.0.1 to Android 8.1. The previous trip logging behavior was documented in #5255.

A few tests now with 8.1. Conditions:

Manual trip recording with interval 3 sec (i.e. OsmAnd keeps the GPS running continuously): This seems to work only as long as the device screen is on (both with OsmAnd being the app displayed in the foreground or while another app is shown). As soon as the screen turns off, no points seem logged any more, but logging is resumed as soon as the device is turned on again.

Manual trip recording with interval 30 sec (i.e. OsmAnd shuts down GPS in between): It looks like this works reliably only while OsmAnd is the app displayed in the foreground. As soon as another app is in the foreground, it GPS occasionally comes on and a point is being logged, but e.g. only after 90 sec or so, it is not reliable. While the device screen is turned off, it seems no points are logged at all.

In summary, reliable all-day trip logging seems impossible with OsmAnd now, I am falling back to Android 4.4 devices where this works.

jerous86 commented 5 years ago

My Lenovo YT3 (Android 6, though) also stops recording whenever the screen is turned off. However, I have found that if I have music playing (I only tried so far with Musicolet, and my headphones were plugged in. No idea if any of that matters), then even if the screen is off, my whole trip is recorded consistently nicely to gpx by osmand. Might be worth a try, in addition to the vocal announcements.

MarkusTV commented 5 years ago

Update after update the problem is still there, I give up, uninstalled, bye bye Osmand, totally useless, too frustrating use the app this way.

Marco


Da: jerous86 notifications@github.com Inviato: domenica 23 settembre 2018 23:24 A: osmandapp/Osmand Cc: MarkusTV; Manual Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background (Android 8, EMUI 8) (#5632)

My Lenovo YT3 (Android 6, though) also stops recording whenever the screen is turned off. However, I have found that if I have music playing (I only tried so far with Musicolet, and my headphones were plugged in. No idea if any of that matters), then even if the screen is off, my whole trip is recorded consistently nicely to gpx by osmand. Might be worth a try, in addition to the vocal announcements.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-423849067, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKDZwVcKnXjklJcVgaJPpQ65r13frks5ud_wqgaJpZM4VCUQ4.

sonora commented 5 years ago

Comparing all feedback we have here, it looks to me like we are facing two facets of this isuue:

vshcherb commented 5 years ago

We have potential fix for Android 8.0 though it is possible to do manually in the settings. Recently we've discovered how to fix it on MIUI (Xiaomi) - we need to add to documentation: Battery Settings • Settings App > Battery & Performance > Manage Apps Battery Usage > Power Saving Modes

MarkusTV commented 5 years ago

Maybe every UI and every OS version is slightly different, I do not find anything similar in my Huawei EMUI 8.0. I would be very happy to try this fix if you could add more details, thank you.

Marco

Da: vshcherb notifications@github.com Inviato: lunedì 29 ottobre 2018 14:16 A: osmandapp/Osmand Osmand@noreply.github.com Cc: MarkusTV marco.brun@outlook.com; Manual manual@noreply.github.com Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background (Android 8, EMUI 8) (#5632)

We have potential fix for Android 8.0 though it is possible to do manually in the settings. Recently we've discovered how to fix it on MIUI (Xiaomi) - we need to add to documentation: Battery Settings • Settings App > Battery & Performance > Manage Apps Battery Usage > Power Saving Modes

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-433905390, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKCZDRaMH-D-sRMA6X1-bOORRLE8Dks5upv-HgaJpZM4VCUQ4.

sonora commented 5 years ago

@vshcherb Victor, all my tests on all devices are always reported with the available Android (system) "Power saving" mode turned to "off", i.e. I deliberately change the device's default to see how things behave with all Power management completely disabled. But still I see the e.g. "GPS awake every 5 minutes only" issue on Android 8.1. Or did you mean to mention yet another idea?

@MarkusTV Search your Android settings for keywords "Battery" or "Power", the settings are usually there in all Android versions since 4.x, but in various places, sometimes under Category "Device Maintenance" etc. In newer versions you can also leave Power saving on and white-list apps, but for testing this I find it safer to turn Power management completely off for now.

sonora commented 5 years ago

@vshcherb From my tests:

Issue (1') above, i.e. "the app is killed", may be the one which can be avoided (at least on some devices I tested) if you disable all device Power management. For recording to work then, you need to have recording interval 15 sec or smaller, i.e. keep GPS on all the time.

Issue (2) above (GPS does not fire up when app is in background or device is asleep) is not affected or fixed by Power management, meaning we have a general issue with our service trying to wake up GPS, some process in Android 7/8 devices seems to bundle this and allow it to happen only every 5 minutes, even with Power management set to off.

sonora commented 5 years ago

I am wondering if for Issue (2) we are suffering from this https://github.com/nextcloud/android/issues/2010 and should try the workaround mentioned in StackOverflow, calling startForeground in the Navigation service's onCreate.

EDIT: Tested, creating the notification already in onCreate did not help.

scaidermern commented 5 years ago

If you can reproduce the issue: Does this problem also occur with other GPS tracking apps, like osmtracker? If they don't suffer from this problem then compare how they configure their GPS background service.

Idrive-walking commented 5 years ago

Hi,I used Viewranfer, MapmyHike and Runkeeper for outdoor activity and Google Map for navigation. The only one that never stops recording my activity and is able to keep the gps on in background is Run Keeper, and obviously Google during navigation.

Il giorno 31 ott 2018, alle ore 21:55, Alexander Heinlein notifications@github.com ha scritto:

If you can reproduce the issue: Does this problem also occur with other GPS tracking apps, like osmtracker? If they don't suffer from this problem then compare how they configure their GPS background service.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osmandapp/Osmand/issues/5632#issuecomment-434844304, or mute the thread https://github.com/notifications/unsubscribe-auth/AnjbkytJ1NcHkph1jh5GhThoh3CCL78Dks5uqg5agaJpZM4VCUQ4.

st-anton commented 5 years ago

Sorry for interfering in the discussion; I'm not a app developer, but a sad Huawei Andoid 8 user :-( I searched in the internet and found two documents. I guess the two documents are already known: https://developer.android.com/guide/topics/location/ https://developer.android.com/about/versions/oreo/background-location-limits Especial the second worries me: Does it consequently mean, that Android 8 cannot handle navigation in background? In other words: Does Google navigation (and others) run in forground all the time?

Zahnstocher commented 5 years ago

Especial the second worries me: Does it consequently mean, that Android 8 cannot handle navigation in background? In other words: Does Google navigation (and others) run in forground all the time?

Yes, a foreground service is needed, but this doesn't mean, that the App UI has to be visible. OsmAnd already runs the service in foreground mode: https://github.com/osmandapp/Osmand/blob/0cdbff3454cb3351a603d3e4120f8d661c1a749c/OsmAnd/src/net/osmand/plus/OsmandApplication.java#L839

Bambasti commented 5 years ago

I can confirm this bug. Happens on a Samsung Galaxy S5 Neo equipped with LineageOS 15.1 / Android 8.1. All possible power savings are disabled for OsmAnd+, even for vaguely related apps like GPS Status as well. Still any recording / navigation stops shortly after switching off the screen, GPS gets lost. On my Xiaomi Pocophone F1 that's running Android 9 I don't have these issues. Since I like to use my older Galaxy as a stand-alone navigation tool mounted on my bike this is quite a deal-breaker. Having the screen enabled at all times is not an option. OruxMaps is working fine and recording in the background as intended. So this is not an issue that's impossible to overcome.

MarkusTV commented 5 years ago

You say… “So this is not an issue that's impossible to overcome”: I agree, it is embarrassing how Osmand is ignoring and underestimating this problem which makes the app totally useless.

Da: Bambasti notifications@github.com Inviato: domenica 11 novembre 2018 22:49 A: osmandapp/Osmand Osmand@noreply.github.com Cc: MarkusTV marco.brun@outlook.com; Mention mention@noreply.github.com Oggetto: Re: [osmandapp/Osmand] Track recording doesn't record in the background (Android 8, EMUI 8) (#5632)

I can confirm this bug. Happens on a Samsung Galaxy S5 Neo equipped with LineageOS 15.1 / Android 8.1. All possible power savings are disabled for OsmAnd+, even for vaguely related apps like GPS Status as well. Still any recording / navigation stops shortly after switching off the screen, GPS gets lost. On my Xiaomi Pocophone F1 that's running Android 9 I don't have these issues. Since I like to use my older Galaxy as a stand-alone navigation tool mounted on my bike this is quite a deal-breaker. Having the screen enabled at all times is not an option. OruxMaps is working fine and recording in the background as intended. So this is not an issue that's impossible to overcome.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/osmandapp/Osmand/issues/5632#issuecomment-437708128, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Am7zKNHxv51syzaYxdKZHqZq97gpdkfLks5uuJs6gaJpZM4VCUQ4.

bsidhom commented 5 years ago

I'm now able to quickly reproduce this on my Pixel 3 XL running Android 9.

Steps to reproduce:

  1. Start the OsmAnd GPX logging service with a recording interval under 30 seconds (so the GPS does not sleep).
  2. Turn off the screen and leave the device for a few minutes.
  3. Open the camera app directly and take several photos rapidly (preferably with HDR/motion enabled to increase memory pressure).
  4. Check that the OsmAnd GPX logging notification has disappeared. If not, repeat steps 2-3.

I noticed the following lines in logcat output:

11-19 20:10:59.842   859   859 E lowmemorykiller: /dev/memcg/apps/uid_10018/pid_3892/memory.stat open failed: No such file or directory
11-19 20:10:59.843   859   859 I lowmemorykiller: Killing 'android.process.media' (3892), uid 10018, adj 700
11-19 20:10:59.843   859   859 I lowmemorykiller:    to free 29424kB because system is under low memory pressure oom_adj 100
11-19 20:10:59.843   859   859 E lowmemorykiller: /dev/memcg/apps/uid_10092/pid_5559/memory.stat open failed: No such file or directory
11-19 20:10:59.843   859   859 I lowmemorykiller: Killing 'com.google.android.tts' (5559), uid 10092, adj 201
11-19 20:10:59.843   859   859 I lowmemorykiller:    to free 67036kB because system is under low memory pressure oom_adj 100
11-19 20:10:59.844   859   859 E lowmemorykiller: /dev/memcg/apps/uid_10167/pid_5421/memory.stat open failed: No such file or directory
11-19 20:10:59.844   859   859 I lowmemorykiller:    to free 37032kB because system is under low memory pressure oom_adj 100
11-19 20:10:59.844   859   859 E lowmemorykiller: /dev/memcg/apps/uid_10150/pid_2536/memory.stat open failed: No such file or directory
11-19 20:10:59.845   859   859 I lowmemorykiller: Killing 'net.osmand.plus' (2536), uid 10150, adj 200
11-19 20:10:59.845   859   859 I lowmemorykiller:    to free 288264kB because system is under low memory pressure oom_adj 100
11-19 20:10:59.845   859   859 I lowmemorykiller: Killing because cache 91424kB is below limit 92160kB for oom_adj 100
11-19 20:10:59.845   859   859 I lowmemorykiller:    Free memory is 13792kB above reserved
11-19 20:10:59.845   859   859 I lowmemorykiller: Reclaimed enough memory (pages to free=77192, pages freed=105439)

And below that:

11-19 20:11:00.278  1257  1643 W InputDispatcher: channel '2960ac net.osmand.plus/net.osmand.plus.activities.MapActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
11-19 20:11:00.279  1257  1643 E InputDispatcher: channel '2960ac net.osmand.plus/net.osmand.plus.activities.MapActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
11-19 20:11:00.299  1257  1625 I GnssLocationProvider: WakeLock acquired by sendMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@ac12a1a)
11-19 20:11:00.299  1257  1271 I GnssLocationProvider: WakeLock released by handleMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@ac12a1a)
11-19 20:11:00.311  1257  3397 I GnssLocationProvider: WakeLock acquired by sendMessage(SET_REQUEST, 0, com.android.server.location.GnssLocationProvider$GpsRequest@92f094b)
11-19 20:11:00.311  1257  1275 W libprocessgroup: kill(-2536, 9) failed: No such process
11-19 20:11:00.311  1257  3493 I ActivityManager: Process net.osmand.plus (pid 2536) has died: prcp FGS 
11-19 20:11:00.311  1257  3516 I WindowManager: WIN DEATH: Window{2960ac u0 net.osmand.plus/net.osmand.plus.activities.MapActivity}
11-19 20:11:00.311  1257  3516 W InputDispatcher: Attempted to unregister already unregistered input channel '2960ac net.osmand.plus/net.osmand.plus.activities.MapActivity (server)'
11-19 20:11:00.312  1257  3493 W ActivityManager: Scheduling restart of crashed service net.osmand.plus/.NavigationService in 1000330ms

That last log entry makes it seem like the service should be restarted in about 15 minutes. However, it took about 30 minutes to come up on its own in my test.

So in my case the issue appears to be memory pressure. Is the (foreground) service started with the START_STICKY flag? If not, this could shorten recovery times. I'm not sure there's anything that can be done to prioritize OsmAnd over other long-running services to prevent eviction.

See https://stackoverflow.com/a/9441795 and https://android-developers.googleblog.com/2010/02/service-api-changes-starting-with.html for more details on START_STICKY.

bsidhom commented 5 years ago

If START_STICKY is not robust enough (it seems like there may be a large delay in getting the service restarted), it's possible that JobScheduler with a tight deadline can help bootstrap a restart.

bsidhom commented 5 years ago

Just confirmed that START_REDELIVER_INTENT is being used instead of START_STICKY at https://github.com/osmandapp/Osmand/blob/cdf49f10f616d17214767694f3c7b5333c81201a/OsmAnd/src/net/osmand/plus/NavigationService.java#L170. The documentation is not clear on the nuances of when either should be used but does imply that START_STICKY should be used for services that are explicitly started and stopped (which fits the bill here).

bsidhom commented 5 years ago

Another option might be to use the broadcast hack explained here: https://fabcirablog.weebly.com/blog/creating-a-never-ending-background-service-in-android. My main concern with that approach is that I'm not sure whether broadcasts might be swallowed. That approach depends on the receiver running in a different process than the sender. There appears to be a race between the broadcast, process termination, and broadcast receipt. If the broadcast is received by the process that is sending termination, I suspect it will be lost.