UIDocument related hang in OS code

Hi

A user of my app has contacted me about a crash they’re getting. They’ve sent me some logs (see attached) but I’m having difficulty working out what the cause is as it looks like it’s a watchdog timeout that’s occurring inside OS code, not my application. I also can’t reproduce the crash locally.

App background info: The app logs peoples skydives, each log can contain a lot of data (rotation rates, acceleration, location, speeds, etc) and is stored in a separate file. These files can be stored in an iCloud container so the logs can be viewed from different devices. I use CoreData to maintain a database of key metadata so I can list the jumps in the UI even if the file for a jump isn’t on the device. Occasionally I have to delete this database and rebuild it by loading each jump log file and getting a fresh copy of the metadata. EG this can happen if a new version of the app requires an additional metadata field in the database.

Crash info: The crash looks like it’s happening rebuilding the database, so the app will be trying to download and open each jump log and add the records to the database. I’ve noticed the following odd things about the crash log, which might be a good place to start:

  • There’s a huge number of threads in the “”UIDocument File Access” dispatch queue that are blocked
    • It looks like there's exactly 512 threads blocked in this queue. Which makes me think its hitting a limit.
    • Any idea why they are blocked?
    • I don’t know why there are so many, The database rebuild is done from an operation queue with a max concurrency of 10. So I would expect at most 10 jump logs to be being opened at one time
    • There seams to be two common stack trace patterns. Eg compare thread 1 and thread 5 in crash log 1.
  • In both crash logs the main thread is blocked, but in different bits of OS code in the two crash logs. It looks like this is the cause of the watchdog failure, but I’m not sure what the common cause could be.

Any ideas / help would be really appreciated.

Thanks Tom

NOTE: I had to cut down the crash logs so they were small enough to upload.

UIDocument related hang in OS code
 
 
Q