核心数据导致应用程序崩溃时迁移 [英] Core Data causing app to crash while migrating
问题描述
我向App Store提交了我的应用程序更新,要求更新/迁移Core Data模型。这只是一个简单的改变,一只手加满了新的属性,一个改名。对于大多数用户来说,它似乎已经很好了,但我有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.
崩溃似乎都发生在执行自动推断移民。我的迁移选项为 NSMigratePersistentStoresAutomaticallyOption
和 NSInferMappingModelAutomaticallyOption
。
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
strong>
Report User 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
推荐答案
至于发生了什么。在这两种情况下,Core Data持久性/保存时间过长。该应用程序没有崩溃,由于错误,但它正在被操作系统杀死,因为它没有关闭或及时启动。
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屋!