IOSurface.framework does not appear to be interoperable with the Cocoa XPC API (NSXPCConnection)

Originator:marco
Number:rdar://16754636 Date Originated:2014-04-29
Status:Open Resolved:
Product:OS X SDK Product Version:10.9
Classification:Enhancement Reproducible:
 
Summary:
I'm trying to share a IOSurface object between an OS X app and a bundled XPC service. I'm targeting Mavericks and I'd like to use the Cocoa interface to XPC, rather than the low-level C API. Unfortunately, there doesn't seem to be a way to pass the raw xpc_object_t I get from IOSurfaceCreateXPCObject() over an NSXPConnection, nor to wrap that xpc_object_t in a Cocoa object that NSXPConnection can marshal.

Ideally, I'd like to be able to define a protocol like this:

@protocol LibremonProtocol <NSObject>

- (oneway void)openFile:(NSString*)filename
	surface:(xpc_object_t)surface
	completion:(void(^)(id ebook, NSError * error))completion;

@end

associate it with an NSXPCInterface, and then call openFile:surface:completion on the NSXPCConnection's remoteObjectProxy, passing the return value from IOSurfaceCreateXPCObject() in the surface: parameter.

Steps to Reproduce:
1. Set up an Xcode project with an OS X app main target and an ancillary XPC service target;

2. Write boilerplate client/server code to set up and accept an NSXPCConnection;

3. Define an Objective-C protocol with a single method that takes an xpc_object_t parameter;

4. Create an IOSurfaceRef object and obtain an xpc_object_t from it using IOSurfaceCreateXPCObject();

5. Attempt to invoke the protocol method on the remote object proxy;

Expected Results:
The XPC server receives the call, getting an xpc_object_t that can be passed to IOSurfaceLookupFromXPCObject() to get a usable, shared IOSurface.

Actual Results:
Attempting to call the remote object proxy throws an exception:

*** -[NSXPCEncoder _checkObject:]: This coder only encodes objects that adopt NSSecureCoding (object is of class 'OS_xpc_mach_send').

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!