Tag: 死锁

使用AFIncrementalStore和NSFetchedResultsController死锁

这几天我一直在抨击我的头,不能为我的生活弄清楚是怎么回事。 我非常青睐核心数据,但我知道这足以避免死锁的情况。 然而,对于这个项目,我决定尝试并纳入AFIncrementalStore。 我构build了一个示例项目来testingAPIClient,以便恰当地映射键/值而不会干扰我的实际项目。 它工作完美无瑕。 现在我在我的实际项目中使用它,事情是挑剔的。 NSFetchedResultsController被用在一个UITableViewController中,这个UITableViewController被推出屏幕(在类似于Facebook应用程序的菜单中滑动)。 大约有50%的时间我没有陷入僵局。 我已经确定NSFetchedResultsController managedObjectContext和我的AppDelegate是一样的。 几乎所有的设置都与AFIncrementalStore示例相同。 即使我的示例项目,以testing使用完美的作品。 当我在死锁期间暂停时,以下是Debug Navigator的图像。 它看起来像AFIncrementalStore的后台上下文和主线程的上下文之间的问题。 但是我不知道该怎么做,因为我没有写AFIncrementalStore,而是刚刚离开现有的文档/示例。 编辑:添加第二个线程的回溯 thread #2: tid = 0x2103, 0x925d180e libsystem_kernel.dylib`semaphore_wait_trap + 10 frame #0: 0x925d180e libsystem_kernel.dylib`semaphore_wait_trap + 10 frame #1: 0x0258cf08 libdispatch.dylib`_dispatch_thread_semaphore_wait + 16 frame #2: 0x0258ab3a libdispatch.dylib`_dispatch_barrier_sync_f_slow + 149 frame #3: 0x0258aa5c libdispatch.dylib`dispatch_barrier_sync_f + 37 frame #4: 0x00b64c8b CoreData`_perform + […]

performBlockAndWait创build死锁

我正在写一个执行一些CoreData的东西的函数。 我希望函数只有在所有的CoreData操作执行后才返回。 CoreData的东西包括在后台上下文中创build一个对象,然后在父上下文中做更多的事情: + (void) myFunction NSManagedObjectContext *backgroundContext = [DatabaseDelegate sharedDelegate].backgroundContext; [backgroundContext performBlockAndWait:^{ MyObject *bla = create_my_object_in:backgroundContext; [backgroundContext obtainPermanentIDsForObjects:[[backgroundContext insertedObjects] allObjects] error:nil]; [backgroundContext save:nil]; [[DatabaseDelegate sharedDelegate].parent.managedObjectContext performBlockAndWait:^{ [[DatabaseDelegate sharedDelegate].parent updateChangeCount:UIDocumentChangeDone]; // Do some more stuff NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue addOperation:someOperation]; }]; }]; return; } 我希望返回只发生在[queue addOperation:someOperation] 。 这似乎工作大部分的情况下,但我有一个案件,当这个function从来没有返回。 它似乎是僵局,我怀疑这是因为performBlockAndWait 。 我的问题是: (1)有人可以解释为什么会发生这种僵局吗? […]

在生产环境中使用数据集debugging应用程序的任何方式?

Production Environment我的CloudKit数据集比Development还要大一些,其他的奇异的差异也可能存在。 在生产模式下使用我的应用程序有一个讨厌的僵局 。 是否有可能以任何方式debugging客户端? 或者我应该尽可能多地login并发送出去? 这是一个线程问题,所以如果不检查Xcode中的线程,实际上是要做任何事情。 任何想法? 我正在使用核心数据本地存储。

核心数据locking在后台线程中

我在核心数据锁。 我真的不明白原因。 因为我在后台线程中处理时正在创build后台MOC。 下面你可以看到什么是堆栈跟踪(我暂停应用程序的执行)看起来像这样的时候: Thread 1, Queue : com.apple.main-thread #0 0x32d2a0fc in __psynch_mutexwait () #1 0x3608b128 in pthread_mutex_lock () #2 0x365d2dac in -[_PFLock lock] () #3 0x365e3264 in -[NSPersistentStoreCoordinator executeRequest:withContext:error:] () #4 0x365e1e2a in -[NSManagedObjectContext executeFetchRequest:error:] () #5 0x3664a93e in -[NSManagedObjectContext(_NestedContextSupport) _parentObjectsForFetchRequest:inContext:error:] () #6 0x3664b0c8 in __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke_0 () #7 0x3932bd28 in _dispatch_barrier_sync_f_slow_invoke () Thread […]