Files in shared folders in iCloud Drive are reverted after save when edited by NSDocument based apps

Originator:anton
Number:rdar://FB10035613 Date Originated:2022-06-02
Status:Open Resolved:
Product:iCloud Product Version:
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
1. Share a folder from a secondary Apple ID to you primary Apple ID
2. Open TextEdit on Mac signed into the primary Apple ID
3. Keep Finder window nearby to see the file sync progress of the file
4. Create a plain text file with some text at the root of the shared iCloud Drive folder
5. Open the same document in TextMate (optional, but useful for another confirmation of what’s happening)
6. Type some more text into the file. 
7. ⌘-tab to TextMate. Switching to another app causes TextEdit to autosave the file
8. Watch file sync progress until it settles down. If you didn’t see the file revert, repeat steps 6–8 until it does

You can see a screen recording of the issue at https://twitter.com/antons/status/1532444431793766419.

In the screen recording the file lost all recent modifications for 5 full seconds (5 bytes started → 50 bytes saved → 5 bytes reverted by iCloud Drive → 50 bytes), as shown by both TextEdit and TextMate.

This is consistently, repeatedly, easily reproduble when using TextEdit, iA Writer — both NSDocument and NSFilePresenter based apps. I couldn’t reproduce the issue when I saved the file only in TextMate, which does not use NSDocument and NSFilePresenter. 

When debugging this, you can breakpoint at -[NSDocument relinquishPresentedDataToWriter:] to catch the exact moment when iCloud Drive reverts the file.

Comments


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!