• General
  • Regression in GrapheneOS? Apps are aggressively killed by OS in the background

ryrona If you have apps losing data when gracefully unloaded from memory, that needs to be reported to the app developers. Simply rotating the screen respawns app activities by default along with many other things. Apps are not supposed to just mark many configuration changes as handled by themselves while not ever actually implementing saving/restoring their state. Browsers are known to not handle this particularly well and that's not in any way unique to GrapheneOS. Other apps generally handle it just fine.

If you open the Settings app, go to Apps, Vanadium, Battery Usage, is Allow background usage enabled?

This isn't really relevant to this.

Orange The maximum number of profiles which can be used at the same time is a very separate thing from Android unloading inactive apps to make room for other usage of the memory along with Chromium-based browsers setting up tabs to be separately unloaded in a similar way.

GrapheneOS If the apps lose data due to being unloaded from memory, those apps are buggy and need to be fixed. Android apps are supposed to gracefully handle being unloaded at any time.

What about incognito browser tabs, would they also be closed? As far as I know they're always kept only in RAM, so when RAM becomes short they're (as a last resort) killed.

GrapheneOS I never had any issues with rotating the screen. But many apps lose any half-typed message that has not yet been sent or posted if unloaded. Many others lose their scroll position. Some even jump back to their home screen or default dashboard. Vanadium is one example of an app that is handling this especially poorly. But every single end-to-end encrypted chat app I have tried also cannot handle being unloaded without losing my half-typed message.

I understand apps are supposed to be able to handle being unloaded gracefully, without losing any state, but the truth is that this seem to rarely be handled well. Many apps cannot be put in restricted battery usage because of this.

Does anyone have Battery Saver activated?

  • Edited
  1. Opened a website https://editpad.org (I dont even know how good editpad.org is by the way, just the first online text editor that showed up for me) in primary user in vanadium
  2. Typed some text into it.
  3. Switched to a secondary user which hadn't been unlocked yet
  4. Did some stuff there like open camera, check gallery, open browser
  5. Closed that session and switched back to primary user
  6. Well, the website did need to load again, but my progress there was saved
  7. Tried the same steps with https://editpad.org in incognito tabs
  8. When opening vanadium in primary user, it opened the incognito tabs with my progress saved

All this on a pixel 6a.
I am not sure what's going wrong here, perhaps tell us what kind of activity and for how long
you're using secondary profile. Just light switching/using doesn't seem to produce these effects on a 6a.

Very little configuration changes on my part. No developer options.

    Ok there is one thing though, I only had vanadium active on my primary user.

    • thmf replied to this.
      • Edited

      ayaen I used to have a similar issue and hope the post will help a bit. Last time I tested this was maybe a year ago or so. In my scenario profiles are used the other way around. It used to be like this:
      I open Vanadium in secondary profile, open my bank web site, try to login, then it sends you 2FA SMS (security, right?) which I used to receive in default GrapheneOS messaging app in owner profile. So I switch to the owner profile, check the 2FA code, switch back to the secondary profile, and Vanadium page gets reloaded, so no option to enter the code. Login again, sends new code, etc...
      The secondary profile was setup to run in background.
      I don't know if this is still true, since I don't use that bank and don't receive SMS messages anymore (by choice), so sadly can't test.
      Tried to swipe up Vanadium to put it in background in secondary user, tried to leave it active on screen while changing the profiles - no difference.
      The only thing I can't recall is if the tabs were regular ones or incognito.
      Hope this helps in any way.

      ayaen Opened a website https://editpad.org (I dont even know how good editpad.org is by the way, just the first online text editor that showed up for me) in primary user in vanadium

      You probably found one of the few internet sites that actually save your state themselves to their remote server. Any text you have typed into a regular HTML POST input-text field will not be preserved like that.

      The strange thing is: When using Private Space, no apps get killed at all. Everything works as expected.

      The moment I switch to any regular user profile, all Vanadium Tabs (regular or private ones) are gone. Always. Other apps seem to be uneffected and I can continue right where I left.

      Sometimes even my always-on VPN App has trouble. I receive a notification from the Owner Profile/VPN App. Usually when switching back to the Owner, everthing seems fine. But at least once I had to manually open/reconnect the VPN App because it was "killed" for whatever reason.

      Device: Pixel 9
      GrapheneOS 2025021100

      a month later

      I've been having this same issue since I got my Pixel 8. I've only used developer settings for enabling wireless debugging to test mobile app development.

      I've raised the issue before in Matrix and was told to disable developer settings and that there's nothing in the way GOS works that would cause this so it's probably something with my configuration. Disabling dev settings hasn't helped.

      Multitasking on this phone is a nightmare. If I swap to an app to copy something, there's a good chance when I swap back, the app will be killed.

      I asked around in the pixel_phones reddit if other users are having this issue and no one else there seems to be experiencing it. But here in the GOS forums, there's been a few threads about it. So it definitely seems GOS related to me.

      For reference, I do not use a secondary profile but I do have a work profile configured with Shelter. I've also had two Pixel 8's and both have had this problem. When I got the second one (via warranty replacement), I set it up from new without using backups specifically to test out this issue.

        mike616 Personally I'm having a hard time grasping what everyone means by "kill", because there are several things that could mean (crash, ANR, etc.). Perhaps a screen recording of the "killing" would help people understand the symptoms. And might even help people in trying to reproduce the "killing"!

          mike616 You can try with secure app spawning disabled to reduce per-app memory usage. It's a toggle in the exploit protection menu. Significantly reducing the extra memory usage it requires would be extraordinarily difficult and it makes a big security difference. It's not an enormous amount of additional memory usage and we've been using it on much older devices with only 4GB memory, etc. Newer devices do cache a lot more apps in memory.

            fid02 I don't believe the apps are crashing or going ANR in the background. It's just that if I switch away from an app and switch back to it only moments later, the app behaves as if it's being launched for the first time, losing its state. This is the same behavior you would see if you "Force stop" an app and re-open it.

            With a browser, this usually means reloading the current tab. For other apps, there's a few seconds of startup before the app is ready and I usually end up at the main page of the app, not the view I left it on.

            This seems to me like Android is killing the app in the background to free up memory.

            GrapheneOS I've disabled Secure App Spawning per your recommendation. The phone feels a bit more snappy now switching between apps. I'll report back in a few days if this helps in the long run. Thank you.

            5 days later

            So far, it looks like disabling Secure App Spawning is doing the trick. I haven't noticed the launcher being killed at all in the last few days and switching between apps seems to be working as expected (no immediate killing of background apps).

            I'm not sure why only a subset of Pixel users are experiencing this problem, but if there's any logs I can provide, please let me know.