khaytsus wrote:deeggo wrote:Some thoughts on Waze closing in the background.
Since a couple of weeks I changed my HTC DesireHD for a HTC One X. I found out fast that Waze closes more often in the background on my new device than on my old, although its specs are higher. That has been this way with the current market version and the last 3.4.99 betas. Switching from Waze to the gmail app and reading an e-mail can be enough to trigger this.
With closing in the background I mean that the Waze icon stays in the task bar, but when switching to it, Waze relaunches as if it wasn't running at all.
Apparently, the One X (or Android 4) memory management is more aggressive. I'm never using any task killers.
Here's some info on this subject, that was found during the development of Flitsnav, a Dutch GPS program that was experiencing exactly the same during development. I hope it can help you improve this behaviour, since several users are reporting this.
Waze closing in the background has to do with Android's Out Of Memory (OOM) management.
Some info on OOM_adj (-17 tot +15): The LOWER the value, the MORE important Android thinks the process is.
Foreground Application: -16 to 0
Visible Application: 1
Secondary Server: 2
Hidden Application: 3 to 7
Content Provider: 8 to 14
Empty Application: 15
Maybe you can adjust Waze, so that it sets is own OOM_adj to -17 and repeats that every 5 seconds for instance?
I've been (attempting to) research this more to help provide specific info on how they can help here.... -17 isn't possible without root, and I believe the app must be a system app to do this at all. And in reality, -17 is probably not a good idea.
startForeground was my next idea, but according to Google engineers this is also a bad idea, unless you want your app running 24/7. We don't really want that.
So I dug into what Waze is running as today using an app called AutoKiller Memory Optimizer (no, it's not a task killer, it's pretty cool low level view of OOM levels etc on apps etc), and it seems to always be a "Hidden app" or "Previous app" in Jelly Bean, which puts it somewhere between 7-9 on the OOM kill list. Lower is better. A "Perceptible service" is better, at around 2, but I'm failing to find how to specify that in the app code/manifest... I think if Waze can figure out how to set itself as a "Perceptible service" it'll unlikely get killed unless memory is truly low.
Today, Waze seems to have the same priority as any other background app, and since it's large it'll probably be highest on the list to be killed. I've pondered some of the tweaks/patches that adjust the ICS/JB OOM priority list but I don't want to patch my ROM constantly, and of course that would only help me out. So it'd be nice if the Waze guys can figure out a way to lower their OOM priority while the app is in the background. I'm sure it can be done, but I can't find any details offhand on what to specify in the startup or manifest or such.
I'm going to experiment with making Waze a system app.. Just for giggles, see what happens. I've heard system apps have better (lower in number) priority and are "harder" to kill.
One more post on this subject.. I've talked to the Tasker dev a bit about this, since I found the following..
If I use Autokiller (a task viewer, lets me see some details) for Tasker I see:
OOM 1, OOM group: Visible, Importance: Visible.
OOM: 7, OOM Group: Content Provider, Importance: Background
His suggestion is that maybe that Waze is not doing startForerground method in the Service class.
http://developer.android.com/reference/ ... ication%29
But I'd think this was already being done in Waze. Tasker stays at its settings mentioned above, where I've seen Waze as "Foreground" or "Vislble" and OOM:2 then a few seconds later, it's "Content Provider" "Background" and OOM 7-9. Again, I wish I knew anything about actual Android development to make more specific suggestions on what to change.