Problems with XPC endpoint connection

XPC connection keeps getting interrupted.

  1. I'm creating an xpc endpoint in FxPlug plugin for FCP X using xpc_endpoint_create.
  2. This endpoint is then passed to a helper mach service running in the background and stored there.
  3. Next, our main application is launched and retrieves the stored endpoint from the helper service.
  4. It creates the communication channel using xpc_connection_create_from_endpoint
  5. The main application communicates with FxPlug plugin using that endpoint.

It all works well when I am debugging either our application or FxPlug.

The moment I use the release build on both, the connection works fine for a while but is very quickly interrupted (usually 2-10 seconds), FxPlug plugin gets flagged as non-responsive and is unloaded by FCP X. This behavior is erratic and may cease after some time on some machines.

We've been working on this and some other issues with FxPlug team for months and some changes have been made, but we're stuck with that one last bit.

I want to stress the following: when I use a debug version of either plugin or our app, everything works fine, fxplug is never unloaded or marked as unresponsive, the connection is stable. When both components are using release builds, it all comes apart for no apparent reason.

Both plugin and application can normally recover and reconnect after being unloaded and restored.

Any thoughts on why an xpc connection would be interrupted in this way?

When both components are using release builds, it all comes apart for no apparent reason.

My first step in debugging situations like this is to get a better handle on what “release build” means. A release build typically gloms together three different concepts:

  • The code was compiled with optimisations enabled, that is, the Debug vs the Release build configuration.

  • The code was signed for deployment, as opposed to development

  • The code is being run under the debugger.

If you can tease these apart that’s an important first step in debugging the problem. For a standard app built with Xcode there’s a number of easy tests to run:

  • If you start with an Xcode archive, export that archive with development signing. If the problem persists, you know that deployment signing isn’t the problem.

  • Tweak the Run action in your scheme to run a Release build configuration. If the problem then starts showing up, it’s likely that optimisation is the issue.

    Note The debugger will be severely hampered when working with your optimised build but that doesn’t prevent you from reproducing the issue.

Clearly your product is more complex then a simple app, and you may not even be building it with Xcode, but you should be able to adapt these techniques for your setup.

Also, because IPC is involve you can run more tests to tease apart the client and the server aspects of this. So, for example, you could replace just one component of your product at a time with a release build to work out which one triggers the issue.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I would like to add, that the same IPC code also works fine with FxPlug 3. It only breaks down inside FxPlug 4, where the plugin is ran as a separate service.

Problems with XPC endpoint connection
 
 
Q