Wrong fetch request with batchSize behaviour from iOS 14 beta 5 onwards

Number:rdar://FB8562978 Date Originated:08/28/2020
Status:Open Resolved:
Product:iOS Product Version:14 beta 6
Classification: Reproducible:always
On iOS 14 beta 5 and 6, when fetching a request on a new private queue context that has persistentContainer.newBackgroundContext() as a parent, returns the wrong number of objects (always 0 even if there are objects in the db).

The same code on iOS 13 and iOS 14 beta 1 to 4 returns the correct number of objects.

The attached project runs ok on Xcode 11 and up to Xcode 12 beta 4. On Xcode 12 beta 5 and 6 the assertion fails.

How to reproduce:

Create a new object of your CoreData entity on the viewContext
Save the viewContext

Create a NSFetchRequest for all objects of such entity
Run the fetch request on the persistent container's viewContext (on the main thread)
Set fetchBatchSize to 20
Obtain a background context from the persistent container
Obtain a new context and make the background context the parent context
Run the same fetch request on the new context

Expected result:

Both requests should return the same number of objects (1 if we run the program with an empty db)

Actual result:

The request on the main thread returns 1 object. The request on the background context's child context returns 0 objects.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!