7

这是我在 Apple 论坛上创建的主题的副本

背景

我在 App Store 中有一个已建立的应用程序,该应用程序NSPersistentCloudKitContainer自 iOS 13 以来一直在使用,没有任何问题。我一直在运行 iOS 15 测试版的 iOS 设备上正常运行我的应用程序,主要是为了在我的用户看到问题之前发现问题。自iOS 15 beta 4以来,我的应用程序无法同步更改 - 无论更改多么小。上传“开始”但从未完成。大约一分钟后,应用程序退出到主屏幕,并且无法从崩溃报告中收集到任何有用的信息。直到现在我都不知道发生了什么。

API 中可能存在的错误?

在 iOS 15(beta 5)上使用 Xcode 13(beta 5)构建我的应用程序时,我设法在模拟器和另一台设备上复制了这种行为。似乎NSPersistentCloudKitContainer存在内存泄漏并不断增加 RAM 消耗(以及 100% 的 CPU),直到操作系统终止应用程序。我的代码没有运行。我并不是这些方面的专家,我尝试使用 Instruments 来看看这是否能告诉我任何东西。它似乎与以NSCloudkitMirroringDelegate某种方式“卡住”有关,但我不知道如何处理这些信息。我的核心数据数据库并不小,但无论如何也不庞大,而且NSPersistentCloudKitContainer在 iOS 15(beta 4)之前同步到 iCloud 没有问题。如果我恢复我的应用程序数据(从外部备份文件 - 700MB 有很多多对多、多对一关系、ckAssets 等),所有数据都会毫无问题地添加到核心数据中。控制台日志(见下文)然后显示同步已创建、计划和然后开始......但没有上传任何数据。此时内存消耗开始,我看到的只是出现“backgroundTask”警告(仅与 CloudKit 相关),没有运行我的代码。

CoreData: CloudKit: CoreData+CloudKit: -[PFCloudKitExporter analyzeHistoryInStore:withManagedObjectContext:error:](501): <PFCloudKitExporter: 0x600000301450>: Exporting changes since (0): <NSPersistentHistoryToken - {
    "4B90A437-3D96-4AC9-A27A-E0F633CE5D9D" = 906;
}>

CoreData: CloudKit: CoreData+CloudKit: -[PFCloudKitExportContext processAnalyzedHistoryInStore:inManagedObjectContext:error:]_block_invoke_3(251): Finished processing analyzed history with 29501 metadata objects to create, 0 deleted rows without metadata.

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:](2800): <NSCloudKitMirroringDelegate: 0x6000015515c0> - Beginning automated export - ExportActivity:
<CKSchedulerActivity: 0x60000032c500; containerID=<CKContainerID: 0x600002ed3240; containerIdentifier=iCloud.com.nitramluap.Somnus, containerEnvironment="Sandbox">, identifier=com.apple.coredata.cloudkit.activity.export.4B90A437-3D96-4AC9-A27A-E0F633CE5D9D, priority=2, xpcActivityCriteriaOverrides={ Priority=Utility }>

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate executeMirroringRequest:error:](765): <NSCloudKitMirroringDelegate: 0x6000015515c0>: Asked to execute request: <NSCloudKitMirroringExportRequest: 0x600002ed2a30> CBE1852D-7793-46B6-8314-A681D2038B38

2021-08-13 08:41:01.518422+1000 Somnus[11058:671570] [BackgroundTask] Background Task 68 ("CoreData: CloudKit Export"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

2021-08-13 08:41:03.519455+1000 Somnus[11058:671570] [BackgroundTask] Background Task 154 ("CoreData: CloudKit Scheduling"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

只是想知道是否其他人也有类似的问题?在 iOS 15(beta 4)之前同步初始数据库恢复从来没有问题,并且在安装 iOS 15(beta 4)之后问题就开始了。我已将此提交给 Apple 反馈并正在等待回复 (FB9412346)。如果这是无法解决的,我真的有麻烦了(我的用户会很生气)。提前致谢!

编辑:它似乎已从 iOS 15.2(beta 2)解决,但 Apple 的官方说法是“未解决”。我怀疑这是因为它仍在测试中,当 15.2 公开时它很可能被标记为已解决

4

0 回答 0