Bug: Ingress Prime labels itself as cache memory on Android, causing it to constantly close.
As this is my field of study, I did a fair bit of reading and discussion with developers on why this is an issue and how to prevent Ingress Prime from closing very quickly on devices when the home screen is entered.
Short version for those who don't want to read all of this: When you go to the home screen from Ingress Prime, especially on phones with RAM of four gigs or less, Android is highly likely to **** the biggest, least priority task on its cutting board. 99% of the time, that's Ingress Prime because it doesn't prioritize itself and is huge. This can be fixed by changing the app to either not cache memory and stay running and idle in the background or by giving users the option to add a sticky notification that Ingress Prime is running, causing the app to avoid more undesirable shutdowns. This needs to be implemented on Android for phones with lower memory capacity.
Long version: Android, which is based on Linux, has a memory management tool known as out of memory. When your device is close to (or is entirely, which is rare) out of memory, this will trigger at set intervals, and will cause the kernel to eliminate applications that are larger at lower priorities. So if it sees a big chunk of memory being eaten by an app lying around, usually as cache memory, it kills it.
Android has a few levels of memory management and how much it will allow to be consumed by each level. This is to prevent applications from being terminated for no reason and, most importantly, never running out of memory, because that would flat out crash your phone and require you to pull the battery.
For example, if a phone has four gigabytes of memory, it may allot the following levels: 1000 MBs to background/cached tasks, 500 MBs to secondary containers, and 250 MBs to primary containers. This means that when your phone has less than 1000 MBs of memory free out of its 4000, it will attempt to **** cached tasks. 500, and it kills secondary tasks (these are tasks that are actively running but not at the front. This can include apps with a frozen notification, music players, navigation apps, etc). It then reserves half of the remaining 500 MBs for the primary app, and only clears that app or other sources of memory usage if it needs to (this is a very quick summary, and a fair bit of this might not be completely accurate or correct. I'm summarizing this to explain the issues with prime).
So where does Prime go wrong? Well, being on the unity engine, prime is consistently using around 400 MBs of RAM, or 10% of the Pixel 2/XL's, 3A's, V30's, etc, RAM. This is a HUGE amount, and is unparalleled by most applications a user would be running. Which is fine, the phones have memory for that. The issue comes out of how prime handles its memory when you do something like, say, open the camera or the portal submission screen, or go to the home screen to check an app. It doesn't. It does nothing to preserve its memory, and basically tells the phone "hey, the user is done with me and I absolutely do not matter and my existence is empty and meaningless, go ahead and just **** me, it's all good." It's not all good, and this means the phone is incentivized to **** this task that you, the user, want to keep running, and immediately free up 10% of your phone's memory. It's a large amount of memory with no priority whatsoever attached to it.
Niantic, please give us a way to stop Prime from being killed by Android. A notification, or changing to an active secondary task. Or like, ANY dev tactic to stop Prime from dying while navigating with intel open, or playing under an anomaly, or operating, or like ANYTHING. It's a huge headache and makes playing the game while submitting portals and multitasking painful.
Comments
Great analysis! I was trying figure out what's wrong with memory absorption of Prime, but without root can't much do on Android. "free" command shows only overall RAM usage, "top" shows nothing, "htop" can't work without root. Good to know about tasks levels.
After starting Prime and do few hacks the app is using about 460 MB of RAM (my device has only 3GB). After scrolling down 230+ keys and do a few recharges game eats now 560 MB RAM and will freeze soon. I thking that's another problem with memory managment in Prime. Something's wrong with clearing cache from portals pictures.
But multitasking isn't really **** Prime on my device. I can use Telegram, Signal, Gmail and even Google Maps simultaneously with Prime and that's fine, but as soon as I start recharge portals or just scroll down many keys the game freezes.
I suppose technically Prime is a 'low priority' app, in terms of important long running apps like Google Maps etc.
My new phone allows me to context switch between Prime and PoGo seamlessly, and Prime stays active in the background for hours now, due to 6GB RAM.
That's surprising to hear, honestly. My friend with what I believe is a Z2 Play (3 gigs of ram) cant even go to his home screen without the game being closed.
That's not most phones, unfortunately. The average is 4, currently, and it's only a matter of time before 6 gig phones start having issues with prime. Niantic should offer solutions to keep it from being stopped, at the very least.
Seems to be phone-dependent. I'm running it on 2Gb phone without any of glitches described by OP (it just freezes :). 400 Mb used by Prime, 300-400Mb free. My phone thinks it's OK.
But Prime indeed is "Cached background process" and will be first victim to remove when system runs out of memory for other apps.
I'm using Moto G5S with 3GB RAM, and Android 8.1, but it's clean OS without any bloatware. I disabled stock apps which I never use such as Google Assistant, help apps, etc. I keep only necessary apps because I care about efficiency, and I update everything manually (I like read changelog before update anything). So multitasking isn't problem for me because my Android **** rather communicators or browser than Prime. I can keep Prime in background for a few hours, and it's still playable except that god damn keys menu. When I'm in place with many portals performance is very weak, and framerate falls down immediately, so game freezes every 20-30 minutes. I know my CPU is weak and I accept that, but players with hi-end devices also complain about randomly freezes, so buying better phone just for the game is risky.
I also have a 2GB phone and can switch back and forth without problems. Ingress Prime stays alive for a surprisingly long time in the background (which is nice, because it takes two whole minutes to restart).
Maybe later versions of Android have worse behaviour? (I have 6.0.)
New version 2.37.3 solved problem of freezing the game. I'm curious if multitasking work better on your devices after update?