Consume sandbox extension for itemIdentifier (44) with path: 'xxx' from pasteboard failed!

Originator:alex
Number:rdar://24527988 Date Originated:05-Feb-2016 06:46 PM
Status:Open Resolved:No
Product:OS X Product Version:OS X 10.11.3 (15D21)
Classification:Important Reproducible:Yes
 
When dealing with a large number of files (stored in the App Sandbox) and attempting to copy and paste their URLs to the pasteboard (within the app), retrieving them using:

let imageURLs = info.draggingPasteboard().readObjectsForClasses([NSURL.self], options: nil) // causes: Consume sandbox extension for itemIdentifier (44) with path: 'xxx' from pasteboard failed! where xxx is URL from pasteboard.

The source and destination is my app, using files stored within my sandbox, e.g. 2016-02-05 18:35:15.113 Stockpile[2997:538103] Consume sandbox extension for itemIdentifier (30) with path: /Users/Alex/Library/Containers/com.sandatum.stockpile/Data/Library/Application Support/com.sandatum.stockpile/photos/476386606001927/database-export.png from pasteboard failed!

Steps to Reproduce:
1. Store a large(ish) number of files somewhere in the App Sandbox, using boomarks that are NOT security scoped (7,500+ it happens, but with 15,000 it happens very soon)
2. Show those files in an IKImageBrowserView using IKImageBrowserNSImageRepresentationType as the content, and provide that content by reading from the URL.
3. Attempt to drag those files onto an NSOutlineView and in 
NSOutlineView - outlineView:acceptDrop:item:childIndex:, do info.draggingPasteboard().readObjectsForClasses([NSURL.self], options: nil)
3a. When the mouse is released and the drop occurs, the problem will occur.

Expected Results:
Nothing, just works...

Actual Results:
2016-02-05 18:35:15.113 Stockpile[2997:538103] Consume sandbox extension for itemIdentifier (30) with path: /Users/Alex/Library/Containers/com.sandatum.stockpile/Data/Library/Application Support/com.sandatum.stockpile/photos/476386606001927/database-export.png from pasteboard failed!

This happens for most of the files in the pasteboard list.

Version:
OS X 10.11.3 (15D21)

Notes:
I have found a solution, however I don't believe I should be using it?

The app container directory. Upon first launch, the operating system creates a special directory for use by your app—and only by your app—called a container. Each user on a system gets an individual container for your app, within their home directory; your app has unfettered read/write access to the container for the user who ran it. [https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW4]

When I read the URL from the sandbox to retrieve the NSImage, I added stopAccessingSecurityScopedResource() to my code and it works fine.

However, a) this is unbalanced as I never asked to use a security scoped resource, and b) I thought I have full 'unfettered' access to my sandbox?

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!