• 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: Out of process download support
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Out of process download support


  • Subject: Re: Out of process download support
  • From: Scott Hancher <email@hidden>
  • Date: Mon, 24 Feb 2014 14:28:37 -0800

On Sat, Feb 22, 2014 at 12:42 PM, Quinn "The Eskimo!" <email@hidden> wrote:

On 21 Feb 2014, at 16:21, Scott Hancher <email@hidden> wrote:

> However, I never seem to be getting a call to NSURLSessionDelegate's URLSessionDidFinishEventsForBackgroundURLSession: [...]

You should be getting that.  I'd rather spend time figuring out why you don't get it than investigating potential workarounds.

Check that you've spelt -URLSessionDidFinishEventsForBackgroundURLSession: correctly.  I know it sounds silly, but I've been bitten by such bugs before.

Far from silly. I always look for issues like this first. More often than not, it's little items like this that are the problem. For methods I use from Apple headers, I typically copy and paste, so this one doesn't typically bite me, and it was fine in this case.
 

When you get launched and 'handleEventsForBackgroundURLSession' is called, after creating the session call -getTasksWithCompletionHandler: to check that there's no unexpected tasks in your session and to check on the state of your expected tasks.

Curious if that call is actually necessary. I hadn't been calling it. When I recreate the session, the tasks seem to fire right up without this, and I get the delegate calls regardless. I also didn't notice it getting called in the Simple... example.
 

Make sure you call the completion handler passed to this method on the main thread.  It's easy to call it on a secondary thread, and bad things happen if you do.

Yep, it's being called on the main thread.
 

Run the Simple Background Transfer sample to verify for yourself that the method can actually get called.

The example runs fine and calls URLSessionDidFinishEventsForBackgroundURLSession: as expected. Even when I added an exit() call to test an app crash, it was called correctly. The difference in delegate calls did lead me to the problem, however. In our test app, URLSession:didBecomeInvalidWithError: was getting called, but wasn't in the Simple... app. Turns out we were blindly calling finishTasksAndInvalidate on the NSURLSession instance whether a pending system completion handler existed or not. This ended up preventing the call to URLSessionDidFinishEventsForBackgroundURLSession: We're now getting the callbacks as expected.

Thank you for your help. It's greatly appreciated.

++Scott.


Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Out of process download support (From: Scott Hancher <email@hidden>)
 >Re: Out of process download support (From: Fritz Anderson <email@hidden>)
 >Re: Out of process download support (From: Scott Hancher <email@hidden>)
 >Re: Out of process download support (From: Scott Hancher <email@hidden>)
 >Re: Out of process download support (From: "Quinn \"The Eskimo!\"" <email@hidden>)

  • Prev by Date: ipf_output_func behaviour with mbuf chaning
  • Next by Date: unsubscribe
  • Previous by thread: Re: Out of process download support
  • Next by thread: How to post question?
  • Index(es):
    • Date
    • Thread