Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, it's possible. Here is an example: <a href="https://github.com/krevis/RemoteLayerDemo" rel="noreferrer">https://github.com/krevis/RemoteLayerDemo</a></p> <p>Run the app, press the "Get Remote Layer" button, and the service will be started and will give the app a green remote layer. (Oddly, it takes several seconds to appear -- no idea why.)</p> <p>After that, the "Change Color" button sends a message to the service asking it to change the layer's color, which takes effect immediately, and even animates. The "Remove Remote Layer" button removes the layer; the service will then get terminated if you let it idle for a few seconds.</p> <p>The hard part is passing the Mach port of the <code>CARemoteLayerServer</code> between processes. The <code>mach_port_t</code> that you see in your process is just a number; it only has meaning within your process. (Same idea as a pointer: pointers are just numbers, but you can't pass a pointer from one process to another, and expect them to point to the same thing.)</p> <p>You'd think XPC could send Mach ports, but it can't. It would make this a lot easier!</p> <p>Instead, you have to use Mach API to send the underlying Mach port around. In the demo, I'm using <code>bootstrap_register</code> in the app and and <code>bootstrap_look_up</code> in the service, using an agreed-upon name. This is not secure, because any other app in the same bootstrap context could find the port, but it's good enough for a demo. In reality you'd want to <a href="http://fdiv.net/2011/01/14/machportt-inter-process-communication" rel="noreferrer">dive down to some uglier Mach calls</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload