0

Using the simulator, running iOS 13.5, I encountered an intermittent, hard to reproduce issue whereby upon opening a file using UIDocumentPickerViewController (mode: UIDocumentPickerModeOpen), I get two documentPicker:didPickDocumentsAtURLs: calls in a row, a couple of milliseconds apart, containing the same URL.

The document picker itself is presented via a presentViewController call. It may also be relevant that the issue occurs in an Application Extension target. (And yes, for iOS 14+ I do use initForOpeningContentTypes, but that's outside the scope of this question.)

I wasn't able to find a documented explanation as to under what circumstances could this happen, and I don't want to simply dismiss it as a simulator issue that won't occur on actual devices (especially given that the bug occurs extremely rarely, so simply testing it on the device doesn't yield conclusive evidence of the bug not being present). Has anyone else experienced a similar issue?

user1251560
  • 109
  • 7

1 Answers1

1

Don't waste time worrying about the cause. Since the only way this can happen is "a couple of milliseconds apart", the simplest solution is just to debounce and move on. In other words, code defensively. (You could also report a bug to Apple if you have time.)

matt
  • 515,959
  • 87
  • 875
  • 1,141