Core Data concurrency `performBlockAndWait:` NSManagedObjectContext zombie

后端 未结 2 1887
一向
一向 2021-01-26 11:58

I have a following crash report from my released app:

synchronizeMyWords method fetches the entities from database, creates private queue context w

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-26 12:16

    Core Data provides ample APIs to deal with background threads. These are also accessible via Magical Record.

    It looks as if you creating too many threads unnecessarily. I think that the employment of AWSContinuationBlock and AWSExecutor is not a good idea. synchronizeMyWords could be called from a background thread. The block might be run on a background thread. Inside the block you create a new background thread linked to the child context. It is not clear what loadLocalWords returns, or how continueWithExecutor:block: deals with threads.

    There is also a problem with the saving of the data. The main context is not saved after the child context is saved; presumably this happens later, but perhaps in connection with some other operation, so that the fact that your code was working before is perhaps more of a "false positive".

    My recommendation is to simplify the threading code. You should confine yourself to the Core Data block APIs.

提交回复
热议问题