iOS 12无缘无故在后台终止应用程序 [英] iOS 12 terminates apps in the background for no reason

查看:378
本文介绍了iOS 12无缘无故在后台终止应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iOS 12开始,CLLocationManager在后台不再无休止地运行.应用随机终止,没有崩溃日志.在iOS 12之前,此功能运行良好.

Starting from iOS 12 the CLLocationManager doesn't run endless anymore in the background. The app get's terminated without a crashlog at random times. This was working fine before iOS 12.

为演示此问题,我创建了一个示例应用程序此处

To demonstrate this problem I've created an sample app here

该演示应用程序仅启动一个CLLocationManager并使其在后台运行.在后台运行时,我们通过记录日志来跟踪它.问题是该应用程序被iOS终止.创建了演示应用程序来演示此问题.

The demo app just launches an CLLocationManager and keep this running in the background. While running on the background we keep track of it by logging it. The problem is that the app get terminated by iOS. The demo app is created to demonstrate this problem.

复制步骤

  1. 在设备上运行应用程序
  2. 对locationmanager的全面访问权限
  3. 将应用程序置于后台
  4. 等待1-48小时

结果:

  1. 该应用已终止

应用在随机时间后无故终止.

App is terminated without any reason after random time.

预期结果:

  1. 该应用程序仍在运行.

应如何工作

这已得到Apple工程师的确认:

一旦CLLocationManager更新在前台启动,并且您已完成所有工作以使其在后台运行,则位置更新应在后台无休止地运行,直到:

Once the CLLocationManager updates are started in the foreground and you did all the work to have it running in the background, the location updates should run endless in the background until:

  • 应用被强制退出
  • 设备已重新启动
  • 应用程序停止位置更新
  • 应用程序释放CLLocationManager对象
  • 应用崩溃
  • iOS由于内存不足而终止了该应用程序,
  • locationManager对象被释放,过度释放或覆盖.您应确保未实例化视图控制器,这将重置locationController类.如果在后台运行该应用程序时发生这种情况,您将重新启动更新,这将导致该应用程序最终被挂起.您应该确保locationController是单例.
  • 应用崩溃.检查要测试的设备上是否有崩溃日志
  • 由于内存不足,iOS正在终止该应用程序.在这种情况下,您会在显示您的应用被终止的设备上找到JetsamEvent日志.您可以检查时间戳记,并找到与应用程序停止工作有关的时间戳记.

推荐答案

更新后的答案:

Apple修复了iOS 12.2 beta 2(16E5191d)中的此错误

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

原始分析和错误检测:

我们与Apple开发人员技术支持一起使用Sysdiagnose文件分析了此问题.遵循这些指南,您可以安装配置文件以在设备上记录更多日志.我不知道这些日志的工作原理以及在何处可以找到此问题,但是Apple为我完成了此任务,并进行了首次分析:

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:

关于您在2018/10/22 01:01:12:587观察到的暂停事件, 是我看到的(在您上次活动记录后约一分钟)

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]终止于描述: { 所有者=; target = rw.sp.flitsmeister.frameworks.CllocationManagerBackgroundTest; }

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

这基本上是在说您的应用已终止,因为 系统需要驱动器空间,并杀死了许多应用程序,因此可以删除 他们的/tmp和/Library/Caches目录.我看过这个过程 在iOS 12中更具侵略性,但看到您在 256GB的设备,清理后有约179 GB的可用空间,我正在寻找它 很难相信这是合理的.

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.

在发送了更多的系统诊断和复制案例后,Apple竭尽全力进行分析,并得出以下结论:

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.

事实证明,当前在iOS 12中,有一种新机制可以 将定期终止长时间运行的后台应用程序,因为系统 需要释放资源.这时候这个过程也有点 积极进取,我正在与相关团队合作,以实现这一目标 表现得更好.

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.

因此,在这一点上,我希望您提交一个错误报告.解释 症状.并确保您将sysdiagnose文件与 错误报告. (我已经将您的邮件寄出了,但是 以及新的).并且让我知道错误号.

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.

因此,这意味着当前在iOS 12中,您的应用不会在后台无休止地运行.我已经填写了一个错误报告,编号为45581276,将尝试保持该线程更新.

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.

这篇关于iOS 12无缘无故在后台终止应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆