I'm trying to send an IOSurfaceRef across an NSXPCConnection on osx 10.13 and I'm having trouble with the solution that was provided in the forum thread "Efficiently sending data from an XPC process to the host application."
https://developer.apple.com/forums/thread/126716 From that thread:
However, that specific problem got resolved on 10.12 where we introduced a new Objective-C
object, and that object is transportable directly over
Code Block NSXPCConnection |
. So double yay!
But it doesn’t seem to work. I have a very simple service protocol that includes
Code Block - (void)sendFrame:(IOSurfaceRef)frame; |
along with some basic NSString sending methods that successfully transfer across my NSXPCConnection. I have a valid (non-NULL) IOSurface in my app that I send to my helper app with sendFrame, and when the call is executed in the helper, the resulting frame is always NULL.
On the other hand, I’ve also tried creating an IOSurface with the (deprecated) kIOSurfaceIsGlobal property and sending the IOSurface’s ID instead with:
Code Block - (void)sendFrameID:(uint32_t)frameID; |
and
Code Block [_service sendFrameID:IOSurfaceGetID(surface)]; |
And on the helper app side, I look up the IO to get an IOSurfaceRef:
Code Block IOSurfaceRef frame = IOSurfaceLookup(frameID); |
and it works correctly – I get a valid IOSurface which I can display and see the same pixel contents in both the app and the helper.
So what is meant by the new IOSurface object in 10.12 is “transportable directly” over NSXPCConnection? How is it supposed to work? I’m specifically interested in no-copy transfer. Thanks!