Re: Very strange Xpc magic
Re: Very strange Xpc magic
- Subject: Re: Very strange Xpc magic
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 16 Sep 2013 23:33:27 +0700
On 16 Sep 2013, at 23:16, Charles Srstka <email@hidden> wrote:
> On Sep 16, 2013, at 10:27 AM, "Gerriet M. Denkmann" <email@hidden> wrote:
>
>> Maybe I was not very clear.
>> The problem is NOT that the helper app does not start. There just is no helper app, there is nothing which has a MachService called "something.very.silly".
>>
>> The problem is, that the error block, which prints MAGIC_ERROR, does only get called when there is an NSLog right in front of it.
>> This makes no sense (to me).
>
> I just tried your code on my machine, and whether the error logs or not seems fairly random. Whether or not your define is present, I sometimes get the error log and sometimes not, and repeatedly running the app (or putting the code in an IBAction instead of applicationDidFinishLaunching: and repeatedly pressing a button to invoke it) results in a different outcome each time. There might be a race condition in the framework or something.
I also did some more testing. The magic does not lie in the NSLog() but in the elapsed time.
On my machine the sending of a message to remoteObjectProxy must NOT be done earlier than ca. 180 μsec after [NSXPCConnection resume].
Without anything in between these are only 50 μsec apart. Not enough.
NSLog() adds a sufficient delay of almost 250 μsec.
But usleep(130) also does the trick.
Code:
#include <mach/mach_time.h>
...
aCo.remoteObjectInterface = [ NSXPCInterface interfaceWithProtocol: @protocol(ZipProtocol) ];
[ aCo resume];
uint64_t machTime1 = mach_absolute_time();
id ree = [ aCo remoteObjectProxyWithErrorHandler: ^(NSError *err)...
usleep(130);
uint64_t machTime2 = mach_absolute_time();
[ ree command: ...
uint64_t elapsed = machTime2 - machTime1;
double microSec = elapsed * 1e-3;
> Have you filed a Radar report on this yet?
Not yet. Will do tomorrow.
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden