iOS 12 Terminates Apps in the Background for No Reason

iOS 12 terminates apps in the background for no reason

Updated answer:

Apple fixed this bug in iOS 12.2 beta 2 (16E5191d)

Original analyse and bug detection:

Together with Apple Developer Technical Support we have analyzed this issue with Sysdiagnose files. Following these guidelines you can install profiles to have more logging on your device. I don't know exactly how these logs work and where to find this issue, but Apple did this for me and came with this first analyse:

On the suspension event you observed on 2018/10/22 01:01:12:587, this
is what I see (about a minute after your last activity logging)

[CllocationManag:2725] Terminating with description:
{
owner = ;
target = rw.sp.flitsmeister.frameworks.CllocationManagerBackgroundTest; }

This is basically saing that your app was terminated, because the
system needed drive space, and killed a bunch of apps so it can delete
their /tmp and /Library/Caches directories. I have seen this process
to be a little more aggressive in iOS 12, but seeing you are on a
256GB device, and have ~179 GB free after the cleanup, I am finding it
hard to believe this was justified.

After sending some more sysdiagnose and reproduction cases Apple did his best to analyse and ended with the following conclusion:

Unfortunately I don’t bring good news.

It turned out that, currently in iOS 12 there is a new mechanism that
will terminate long running background apps periodically as the system
needs to free resources. At this time, this process is a bit too
aggressive, and I am working with the relevant teams to get this to
behave better.

So, at this point, I would like you to file a bug report. Explain the
symptoms. And make sure you upload the sysdiagnose files along with
the bug report. (I already sent yours in, but it doesn’t hurt to have
the new ones as well). And let me know the bug number please.

So this means that currently in iOS 12 you app won't run endless on the background. I've filled in a bug report, the number is 45581276 and will try to keep this thread updated.

ios12 background location service stopping

This seems to be a bug since iOS 12 that apps will get terminated in background for no decent reason. I've filled in a bug report.

See for more information and a demo project to demonstrate the problem here:
iOS 12 terminates apps in the background for no reason

Bug is fixed in iOS 12.2 beta 2 (16E5191d)

Why iOS terminates background apps instead of handling lack of RAM differently?

Thanks everybody for responses. I had to do some research to answer this question, though. So I was looking for more understanding that led into "app termination" decisions. I know, there are some smart people working in Apple, but for me it always help to understand the reason something is build "this way" rather then just following it.

It turned down into these 2 questions

  • Why iOS terminates apps instead of freeing memory by paging out (swapping)?
  • Does termination provide considerable performance win?

To understand that I dug a bit into the history of iPhone. There's a video that was accessible on iTunes, unfortunately the link does not work anymore. Anyways, the video was introducing the very first version of multitasking on iPhone 3G (or was it 3GS? Not sure which device starts to support multitasking).

Nowadays iPhone devices are quite advanced in terms of hardware. Those are actually more advanced then some desktops we had 7-10 years ago, which already have had incorporated swapping long ago. But if we look for first iPhone releases, those are not that much advanced in terms of hardware. iPhone 3G is 620 Mhz ARM and 128 RAM. iPod touch 1gen had 400mhz ARM. And multitasking was supposed to run on all the devices of that time.

If we take a look at iOS, it was always has the smoothness of animations in priority; taking look at hardware I see it would be challenging to have both snappy and responsive device along with processing swapping background applications memory, so it seems very logical and very fair to terminate apps. A year or two later Apple provided APIs to facilitate implementation state restoration.

But if we look at the current iPhones and iPads - they do have enough power in order not to terminate apps and just drop their memory on disk without any drop downs in animations and foreground app performance. Why not add that on latest devices? I assume this is common for the software industry; new features often prioritised higher then improvements on existing workflows; Apple has been releasing MobileMe, support for Retina displays, AutoLayout, iCloud - so I can understand that cool improvements of already existing features has been sacrificed.

App terminated due to cpu use in iOS 13.2

It turned out, that a third party framework that I am using launches calls to CNCopyNetworkInfo in second intervals. These calls could not fullfilled as my App had no WiFi capabilities enabled and thus the calls to CNCopyNetworkInfo caused small memory leaks that added up over time.

After enabling WiFi access capabilities the memory leaks vanished.

Why is my react-native app terminating in the background while recording (iOS, RN 0.63.3, Expo-Av 9.2.3)

Root causes and solutions

1) Mixpanel (love them!) iOS SDK had a bug, occasionally causing background terminations after 30 seconds.

For context, Mixpanel uses a background task to flush event updates to server every time app enters background. Additionally, iOS automatically terminates apps when a background task has not finished after 30 seconds.

For some reason, these Mixpanel event flushes were sometimes exceeding 30 seconds causing app terminations.

2) Background Out of Memory terminations.

Apple gives very few hints when apps are terminated. Using Embrace.io (awesome company!), I was able to begin measuring occurrences of out-of-memory terminations from the background (BOOMs).

Profiling with react native tools, I was able to identify that even in the background, app re-renders and redux actions in response to Firestore listeners were causing significant CPU usage. Terminating unnecessary listeners and unmounting most screens when entering the background allowed us to significantly decrease background CPU usage, improving battery efficiency and virtually eliminating BOOMs

Happy to elaborate more if anyone has specific questions. Spent a looooot of time on this problem.



Related Topics



Leave a reply



Submit