gpt4 book ai didi

iOS 12 无故终止后台应用

转载 作者:IT王子 更新时间:2023-10-29 08:01:15 24 4
gpt4 key购买 nike

从 iOS 12 开始,CLLocationManager 不再在后台无限运行。该应用程序会在随机时间没有崩溃日志的情况下终止。这在 iOS 12 之前运行良好。

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

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

重现步骤

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

结果:

  1. 应用已终止

应用程序在随机时间后无故终止。

预期结果:

  1. 该应用仍在运行。

它应该如何运作

Apple 工程师证实了这一点:

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

  • 应用被强制退出
  • 设备已重启
  • 应用停止位置更新
  • app 释放 CLLocationManager 对象
  • 应用崩溃
  • iOS 由于内存不足而终止应用程序,
  • locationManager 对象被释放、过度释放或覆盖。你应该确保你的 View Controller 没有被实例化,然后重置 locationController 类。如果在应用程序处于后台时发生这种情况,您将重新启动更新,这将导致应用程序最终被暂停。您应该确保 locationController 是单例。
  • 应用崩溃了。检查您正在测试的设备上是否有崩溃日志
  • 由于内存不足,iOS 正在终止应用程序。在这种情况下,您会发现设备上的 JetsamEvent 日志显示您的应用正在终止。您可以检查时间戳并找到您的应用程序停止运行前后的时间戳。

最佳答案

更新后的答案:

Apple 在 iOS 12.2 beta 2 (16E5191d) 中修复了这个错误

原始分析和错误检测:

我们与 Apple Developer Technical Support 一起分析了 Sysdiagnose 文件的这个问题。关注这些 guidelines您可以安装配置文件以在您的设备上进行更多登录。我不确切知道这些日志是如何工作的,也不知道在哪里可以找到这个问题,但 Apple 帮我做了这件事,并进行了第一次分析:

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.

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

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.

因此,这意味着目前在 iOS 12 中,您的应用不会在后台无限运行。我已经填写了错误报告,号码是 45581276,我会尽量保持这个线程的更新。

关于iOS 12 无故终止后台应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53005174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com