CoreData error: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x174262940, store PSC = 0x0)

Hello,

I am observing the following error message in the console window of Xcode when running my app (on iOS).


CoreData: error: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x174262940, store PSC = 0x0)


I can't seem to pin down the specific operations that are causing it. It almost seems like it is something that Core Data is emitting at some point after whatever the offending operation is.


The Core Data setup in the app is done using a UIManagedDocument and in addition I am adding some private queue concurrency contexts where the parent is the managed context in the document (which is the main). Auto save of the UIManagedDocument is turned on. In addition at certain points the app is also doing explicit save of these private contexts. I don't see any ill affects due to the message but I would like to get to the bottom of the issue.


I did do searching and there was an old posting where someone fixed it by saving their managed context before using a fetched results controller it was associated with. This seems wrong to me as having to a do a save before using the fetched results controller might catch updates to the managed objects that are in the middle of being made and aren't ready for saving yet because a save could end up violating a relationship constraint.


Someone also suggested to make sure the entities were being created with NSEntityDescription.insertNewObject which I double checked that they are.


I have -com.apple.CoreData.ConcurrencyDebug set to 1 and when there were other concrrency issues it helped. However with this particular situation it just emits the message and continues. Is there a way to get Core Data to break in the debugger for his message? Any ideas on how I might get to the bottom of this issue or settings I can enabled are greatly appreciated.


Thanks

Robert

Hi Robert,

Did you make any progress on the issue above,

I am running into the same error and cant seem to find much information on the topic.

Ade

I was running into similar issue and i moved to the new CoreData api introduced in ios10.

This uses the NSPersistentContainer class to create the stack and create associated contexts.

This eliminates the need to manuall call save or order of creation for fetch results controller.


Good blog post to read: https://useyourloaf.com/blog/easier-core-data-setup-with-persistent-containers/


My setup is a follows


//create a store NSPersistentContainer

let persistentContainer = NSPersistentContainer(name: "ModelFileName");


//configure settings

let url = NSPersistentContainer.defaultDirectoryURL()

let path = url.appendingPathComponent(persistentContainer.name);

description.shouldAddStoreAsynchronously = true; //write to disk should happen on background thread

self.persistentContainer.persistentStoreDescriptions = [description];


//load the store

persistentContainer.loadPersistentStores(completionHandler: { (storeDescription, error) in

if let error = error {

fatalError("Unresolved error \(error), \(error.localizedDescription)")

}


//configure context for main view to automatically merge changes

persistentContainer.viewContext.automaticallyMergesChangesFromParent = true;

});



//in the view controller you can access the view context by calling

persistentContainer.viewContext


//if you need to make changes you can call

persistentContainer.performBackgroundTask({ (context) in ... });


//or you can get a background context

let context = persistentContainer.newBackgroundContext()

context.perform({ ... })

Is there any development on this matter? I'm observing the same issue in our code base.


Due to custom configuration and architecture we have in our code base, we won't be able to use the new API sets if they ever fix ths issue.

Same error here, in very simple code. Crazy enough the same code works in playground just not in xcode

I am so new to this, I have no idea what is going on. But, this error stops the UI in its tracks. I think there was a problem in the preview when I did a large .constant(). This froze things, I forced quit and when I came back this is the error listed under errors. I can still run the simulator. But, I cannot run preview. I cannot scroll.

Whiskey Tango Foxtrot

/.../CoreData: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x6000031f48c0, store PSC = 0x0)

Preview quits working.

I'm building an iOS app w/ Flutter and ran into this error after I updated my AppIconset. Couple things to check in your Assets.xcassets folder:

(1) Make sure there are no duplicate assets. (2) One of your asset files might be corrupted, try deleting and saving them to the folder again.

Hope this helps 👍🏽

CoreData error: API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x174262940, store PSC = 0x0)
 
 
Q