I have 2 XPC clients and an XPC server. One of the XPC clients is a binary-helper that serves as a native messaging host for the browserExtension. The other XPC client sends a specific event to the XPC server, which then triggers a Darwin notification. The binary-helper observes this Darwin notification and sends a response to the browserExtension.
Currently, we're considering two options to communicate the response from binary-helper to browserExtension:
- Polling: Every 5 seconds, the browserExtension checks for a response.
- Darwin Notifications: The binary-helper sends a message to the browserExtension as soon as it observes the Darwin notification.
I'm wondering if Darwin notifications are fast enough to reliably deliver this response to the browserExtension in real time, or if polling would be a more reliable approach. Any insights or experiences with using Darwin notifications in a similar scenario would be greatly appreciated.
To have meaningful conversations about real-time computing, you have to specify a time constraint. Without that, we’re just talking about “fast enough, most of the time” (-:
macOS can hit some tight real-time goals pretty consistently, but only in very limited situations. The canonical example of this is audio rendering. The techniques used for that are unlikely to be helpful here. For audio the time constraint is in the tens of microsecond range, whereas I suspect that your time constraint is more like in the tenth of a second range, that is, fast enough so that the user doesn’t notice.
Are those the only processes involved? If so, you shouldn’t need to mess around with Darwin notifications. Rather, do all your IPC using XPC:
-
If you need the two clients to communicate directly, use the server to pass an endpoint between the two.
-
If you need bidirectional communication, there are various techniques you can use. See the summary in this DevForums post.
Finally, I encourage you to have a look at the links in XPC Resources. There’s a lot of important background there.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"