Silent data loss when writing large numbers of objects to NSPasteboard

Originator:bewebste
Number:rdar://17526788 Date Originated:01-Jul-2014 02:51 PM
Status:Open Resolved:
Product:OS X SDK Product Version:OS X 10.9.3 13D65
Classification:Crash/Hang/Data loss Reproducible:Always
 
Summary:
When writing a large number of objects to an NSPasteboard, in some cases, not all the objects will be written to the pasteboard, despite a success value of YES being returned from -[NSPasteboard writeObjects:]

Steps to Reproduce:
Attached is a sample project which demonstrates the problem. A number of basic data objects each containing an NSData can be generated, with the number of objects and size of the NSData specified by two text fields in the main window. These objects are displayed in the table view, and can be dragged out of the table view and dropped on the text field in the lower right, which will display the number of objects it could read from the pasteboard. The code also logs the number of objects it attempted to write, the number of objects successfully written, and the BOOL value returned by the call to -[NSPasteboard writeObjects:]

To reproduce the problem:
1. Build and launch the program. The default values of 33000 objects with 100 bytes of data each have been sufficient in my tests to reproduce the problem.
2. Select all the objects in the table view and drag them to the text field.

Expected Results:
The log statement should indicate that the number of dragged objects and the number of objects on the pasteboard are identical, and after the drop is completed, the text field should display the same number of objects that were dragged from the table view.

Actual Results:
Not all the objects are successfully written to the pasteboard. The number of objects that can be written appears to be proportional both to the number of objects and the amount of data held by each object. With the default settings of 33000 objects with 100 bytes of data per object, the log statement reads:

2014-07-01 14:45:35.473 DragStressTest[1232:303] success = YES, 33000 dragged objects, 32340 objects on pasteboard

Increasing the data size per object will reduce the number of objects written.

Ideally, all objects should always be written to the pasteboard, but in cases where that isn't possible, the -writeObjects: method should at least return NO, indicating there was a problem writing all the objects.

Version:
Xcode 5.1.1 5B1008, OS X 10.9.3 13D65

Notes:


Configuration:
I have run this test code on OS X 10.8.5, 10.9.3, and 10.10 Developer Preview 2, all with the same results.

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!