核心数据导致应用程序在迁移时崩溃 [英] Core Data causing app to crash while migrating

查看:27
本文介绍了核心数据导致应用程序在迁移时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向 App Store 提交了我的应用程序更新,这需要更新/迁移核心数据模型.这只是一个简单的更改,添加了一个充满新属性的手,并重命名了一个.对于大多数用户来说似乎一切正常,但是我收到了 2 个我不明白的崩溃报告.

I submitted an update of my application to the App Store which requires the Core Data model to be updated/migrated. It is only a simple change with a hand full of new attributes added, and one renamed. It seems to have gone fine for most users, however I've had 2 crash reports that I don't understand.

崩溃似乎都发生在执行自动推断迁移时.我的迁移选项是 NSMigratePersistentStoresAutomaticallyOptionNSInferMappingModelAutomaticallyOption.

The crashes appear to all occur while performing automatic inferred migration. My migration options are NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption.

有人知道迁移需要这么长时间吗?每次应用程序启动时都会导致崩溃,因此这些用户无法使用该应用程序.他们都运行 iPhone OS 3.1.2.

Does anyone have any ideas what's taking it so long to migrate? It's causing crashes every time the app launches so the app us unusable to those users. They're both running iPhone OS 3.1.2.

任何帮助将不胜感激.

举报用户 A

com.foo.MyApp failed to launch in time 
elapsed total CPU time (seconds): 19.970 (user 14.130, system 5.840), 92% CPU 
elapsed application CPU time (seconds): 9.910, 45% CPU

Thread 0:
0   CoreData                        0x00093d08 -[NSPersistentStoreCoordinator dealloc] + 0
1   CoreFoundation                  0x0003963a -[NSObject release] + 28
2   CoreData                        0x000b6e0e -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1470
3   CoreData                        0x000aceb0 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 92
4   CoreData                        0x000ad6f0 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 72
5   CoreData                        0x000ac9ee -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 880
6   CoreData                        0x0000965c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 1328

Unknown thread crashed with unknown flavor: 5, state_count: 1

举报用户 B

com.foo.MyApp failed to suspend in time 
elapsed total CPU time (seconds): 18.580 (user 13.320, system 5.260), 93% CPU 
elapsed application CPU time (seconds): 8.340, 42% CPU

Thread 0:
0   libsqlite3.dylib                0x00022f14 sqlite3_backup_init + 2396
1   libsqlite3.dylib                0x00025474 sqlite3_backup_init + 11964
2   libsqlite3.dylib                0x000255dc sqlite3_backup_init + 12324
3   libsqlite3.dylib                0x0002aa74 sqlite3_open16 + 16084
4   libsqlite3.dylib                0x00047838 sqlite3_prepare16 + 46920
5   libsqlite3.dylib                0x00002940 sqlite3_step + 44
6   CoreData                        0x00011958 _execute + 44
7   CoreData                        0x000113e0 -[NSSQLiteConnection execute] + 696
8   CoreData                        0x000994be -[NSSQLConnection prepareAndExecuteSQLStatement:] + 26
9   CoreData                        0x000be14c -[_NSSQLiteStoreMigrator performMigration:] + 244
10  CoreData                        0x000b6c60 -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1040
11  CoreData                        0x000aceb0 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 92
12  CoreData                        0x000ad6f0 -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 72
13  CoreData                        0x000ac9ee -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 880
14  CoreData                        0x0000965c -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 1328

Unknown thread crashed with unknown flavor: 5, state_count: 1

推荐答案

第一行是您了解正在发生的事情的线索.在这两种情况下,核心数据的持久性/保存时间都太长了.应用程序不是因为错误而崩溃,而是被操作系统杀死,因为它没有及时关闭或启动.

The first line is your clue as to what is going on. In both cases the Core Data persistence/saving is taking too long. The app is not crashing due to an error but it is being killed by the OS because it is not shutting down or starting up in a timely manner.

这些用户的数据集有多大?如果它们非常大,那么您可能需要考虑控制迁移并将其放入后台线程或将其分解为多个部分,以便应用程序可以按时启动.

How big are the data sets for each of these users? If they are very large then you may want to consider taking control of the migration and either putting it onto a background thread or breaking it up into pieces so that the application can start up on time.

关闭问题表明您可能没有在应用程序运行时进行增量保存,而是在应用程序关闭时进行了一次大保存.理想情况下,您的应用程序应该在工作流中出现逻辑中断时保存到磁盘.如果您在应用程序中添加了有助于或解决关机终止问题的保存.

The shutdown issue indicates that you are probably not doing incremental saves while the application is running but instead doing one large save when the application shuts down. Ideally your application should save to disk whenever there is a logical break in the workflow. If you add saves into the application that will help or solve your shutdown termination issue.

这篇关于核心数据导致应用程序在迁移时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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