7

My iOS app crashes in production at UIDocument.revert(toContentsOf url: URL, completionHandler: ((Bool) -> Void)? = nil). From the error message, it looks as if the document is supposed to be reverted to itself. For example:

**** Terminating app due to uncaught exception 
     'NSInternalInconsistencyException', 

  reason: 'attempt to revert document at URL (        
    file:///private/var/mobile/Library/Mobile%20Documents/
            iCloud~com~myapp/Documents/sampledocument.test)
    to URL (
    file:///private/var/mobile/Library/Mobile%20Documents/
            iCloud~com~myapp/Documents/sampledocument.test) 
  that is not yet open'

I don't have any specific code to revert the document version and I have not been able to reproduce this myself, but it happens for a number of users.

What would be a scenario where UIDocument would try to revert its contents and why would it try to revert the same file to itself?

Could this be a race condition where the document is closed, but for some reason tries to discard changes?

Mark
  • 6,647
  • 1
  • 45
  • 88
  • Saw this too. iOS 12.2. – Steve Shepard May 28 '19 at 17:53
  • Happening here too iOS 12.3.1. Any clues? – Grimxn Jul 22 '19 at 15:31
  • Mine is a fiplewrapper document, and it appears to be related to closing a document that has not been edited, but whose thumbnail was not previously available on the local client - that is to say that the local client is using the local copy to get a previously un-downloaded thumbnail, but also reverting to the cloud copy as it hasn't changed... – Grimxn Jul 22 '19 at 16:01
  • For me this seems to happen when a change is coming in from another device and I reload (i.e. close and re-open) the document on iOS. `revertToContentsOfUrl` is called twice, the second time the document will be closed. My workaround is to check the document state and ignore the call if the document is already closed... – Mark Aug 12 '19 at 13:43
  • This is related to the iCloud document. I can reproduce this crash if you open a document on the iOS app and delete the document on another device. – Honghao Z Sep 01 '19 at 04:39

0 Answers0