Originally created by @SteveKChiu on GitHub (Jul 23, 2015).
It seems CoreStore can result in deadlock with .beginAsynchronous and ListMonitor, from my experiment:
call CoreStote.beginAsynchronous to insert data
start CollectionView with ObjectListMonitor integration
App hang upon start
If I change CoreStote.beginAsynchronous to CoreStote.beginSynchronous, then all are fine.
I trace the problem and find out:
in CoreStote.beginAsynchronous, the last call is parentContext.saveSynchronously (NSManagedObjectContext+Transaction.swift: 96)
in ListMonitor, the last call is try! fetchedResultsController.performFetch() (ListMonitor.swift: 505)
Originally created by @SteveKChiu on GitHub (Jul 23, 2015).
It seems CoreStore can result in deadlock with .beginAsynchronous and ListMonitor, from my experiment:
1. call CoreStote.beginAsynchronous to insert data
2. start CollectionView with ObjectListMonitor integration
3. App hang upon start
If I change CoreStote.beginAsynchronous to CoreStote.beginSynchronous, then all are fine.
I trace the problem and find out:
1. in CoreStote.beginAsynchronous, the last call is `parentContext.saveSynchronously` (NSManagedObjectContext+Transaction.swift: 96)
2. in ListMonitor, the last call is `try! fetchedResultsController.performFetch()` (ListMonitor.swift: 505)
@SteveKChiu This is probably a confusion caused by having two overloads for AsynchronousDataTransaction's commit() method:
public func commit(completion: (result: SaveResult) -> Void)
public func commit()
You are probably calling the commit() method which was originally named commitAndWait(). In hindsight I should have left the name as it was to indicate blocking behavior. I'll push a fix soon.
In the mean time, you can fix this on your side with either one of two ways:
Call CoreStore.monitorList(...) before CoreStore.beginAsynchronous(...); or,
Inside the closure for beginAsynchronous(...), call transaction.commit { _ in } instead of transaction.commit()
@JohnEstropia commented on GitHub (Jul 23, 2015):
@SteveKChiu This is probably a confusion caused by having two overloads for `AsynchronousDataTransaction`'s `commit()` method:
```
public func commit(completion: (result: SaveResult) -> Void)
public func commit()
```
You are probably calling the `commit()` method which was originally named `commitAndWait()`. In hindsight I should have left the name as it was to indicate blocking behavior. I'll push a fix soon.
In the mean time, you can fix this on your side with either one of two ways:
- Call `CoreStore.monitorList(...)` before `CoreStore.beginAsynchronous(...)`; or,
- Inside the closure for `beginAsynchronous(...)`, call `transaction.commit { _ in }` instead of `transaction.commit()`
I actually had tried the asynchronous one, but it still had the same problem. Anyway, I end up found a solution to the problem, please see my pull request. I am not sure if all modifications are necessary, but I think there is no reason to use the 'wait' version call in most case.
@SteveKChiu commented on GitHub (Jul 23, 2015):
I actually had tried the asynchronous one, but it still had the same problem. Anyway, I end up found a solution to the problem, please see my pull request. I am not sure if all modifications are necessary, but I think there is no reason to use the 'wait' version call in most case.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @SteveKChiu on GitHub (Jul 23, 2015).
It seems CoreStore can result in deadlock with .beginAsynchronous and ListMonitor, from my experiment:
If I change CoreStote.beginAsynchronous to CoreStote.beginSynchronous, then all are fine.
I trace the problem and find out:
parentContext.saveSynchronously(NSManagedObjectContext+Transaction.swift: 96)try! fetchedResultsController.performFetch()(ListMonitor.swift: 505)@SteveKChiu commented on GitHub (Jul 23, 2015):
For develop branch, but I think it apply to main branch too.
@JohnEstropia commented on GitHub (Jul 23, 2015):
@SteveKChiu This is probably a confusion caused by having two overloads for
AsynchronousDataTransaction'scommit()method:You are probably calling the
commit()method which was originally namedcommitAndWait(). In hindsight I should have left the name as it was to indicate blocking behavior. I'll push a fix soon.In the mean time, you can fix this on your side with either one of two ways:
CoreStore.monitorList(...)beforeCoreStore.beginAsynchronous(...); or,beginAsynchronous(...), calltransaction.commit { _ in }instead oftransaction.commit()@SteveKChiu commented on GitHub (Jul 23, 2015):
I actually had tried the asynchronous one, but it still had the same problem. Anyway, I end up found a solution to the problem, please see my pull request. I am not sure if all modifications are necessary, but I think there is no reason to use the 'wait' version call in most case.