• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem using NSTimer in privileged helper tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem using NSTimer in privileged helper tool


  • Subject: Re: Problem using NSTimer in privileged helper tool
  • From: Jean-Daniel <email@hidden>
  • Date: Sat, 21 Oct 2017 21:56:36 +0200

> Le 20 oct. 2017 à 18:56, Quincey Morris <email@hidden>
> a écrit :
>
> On Oct 20, 2017, at 03:23 , Mark Allan <email@hidden> wrote:
>>
>> That worked with the block-based NSTimer API but not the selector-based API.
>>  I tried changing it to 'currentRunLoop' which got rid of the crash, but the
>> timer never fired.
>
> This is pure guesswork, but I suspect this is what was going on:
>
> — When you scheduled the timer on the main run loop, it was actually being
> scheduled on the main app’s run loop. When it was block based, only the block
> had to be passed across the XPC interface (which somehow works), but when it
> was selector-based, the timer itself had to be passed (which doesn’t work).
> Admittedly this is a pretty silly explanation, but it may have some relation
> to the truth.
>
> — When you scheduled the timer on the current run loop, everything was fine
> either way, except the run loop *wasn’t running* in the XPC thread, so the
> timer never fired.
>
> This is similar to a problem that came up on the developer forums a few weeks
> ago. A developer was using Disk Arbitration callbacks to monitor volumes
> being mounted, and tried to move that code to an XPC process. The callback
> was scheduled on the run loop, yet it was never called. There was more recent
> API that was block-based instead, and that turned out to work fine in an XPC
> process. The fact that scheduling on the run loop didn’t crash indicated that
> there *was* a run loop, but the fact that the callbacks didn’t fire suggested
> that it wasn’t running.

There is always a runloop as it is created lazily when accessing it. So the
scheduling will always work. But if the current thread does not call
-[NSRunLoop run] (or a variant), it will never be dispatched.


_______________________________________________

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

References: 
 >Problem using NSTimer in privileged helper tool (From: Mark Allan <email@hidden>)
 >Re: Problem using NSTimer in privileged helper tool (From: Quincey Morris <email@hidden>)
 >Re: Problem using NSTimer in privileged helper tool (From: Mark Allan <email@hidden>)
 >Re: Problem using NSTimer in privileged helper tool (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Problem using NSTimer in privileged helper tool
  • Next by Date: Re: Problem using NSTimer in privileged helper tool
  • Previous by thread: Re: Problem using NSTimer in privileged helper tool
  • Next by thread: Re: Problem using NSTimer in privileged helper tool
  • Index(es):
    • Date
    • Thread