Sandbox breaks copy/paste of images containing PICT (Adobe Fireworks)

Originator:duncan.wilcox
Number:rdar://12774166 Date Originated:2012-11-29
Status:Open Resolved:
Product:Mac OS X Product Version:10.8.2
Classification:Other bug Reproducible:Always
 
Summary:

The common pattern to read an image from the pasteboard is:

        NSArray *pboardContents = [[NSPasteboard generalPasteboard] readObjectsForClasses:@[[NSImage class]] options:nil];

When the image is provided by an app such as Adobe Fireworks, the pasteboard contains a PICT item (com.apple.pict), in a 64bit app the above code eventually calls out to the /usr/sbin/pictd helper app, presumably to decode/render the PICT in 32bit Carbon code.

With the sandbox disabled this works fine, with the sandbox enabled the following error is logged to the console and no image is extracted, even if the pasteboard contains PNG or TIFF representations:

"Could not connect to pict rendering process pictd. Break on void _NSWarnOnceCouldNotConnectToPICTServer() to debug.  This will be logged only once.  This may break in the future."


Steps to Reproduce:

- copy to clipboard in Adobe Fireworks
- paste in a 64bit sandboxed app, such as Prototypes or Sketch

Expected Results:

- pasted image

Actual Results:

- image isn't pasted, actual behaviour varies

Regression:

Works fine with sandbox disabled.

Notes:

Workaround it to manually try and extract PNG or TIFF before letting NSImage give it a shot, such as:

    NSPasteboard *pboard = [NSPasteboard generalPasteboard];
    
    // workaround for images with PICT data in them (copy/paste from Fireworks)
    NSData *imgData = nil;
    if((imgData = [pboard dataForType:NSPasteboardTypePNG]) != nil ||
      (imgData = [pboard dataForType:NSPasteboardTypeTIFF]))
    {
        NSImage *image = [[NSImage alloc] initWithData:imgData];
        // do something with image
    }
    else
    {
        NSArray *pboardContents = [pboard readObjectsForClasses:@[[NSImage class]] options:nil];

        for(NSImage *image in pboardContents)
            // do something with image
    }

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!