WatchBackgroundRefresh sample app does not actually refresh in background

Originator:james.walter.matthews
Number:rdar://28774814 Date Originated:14-Oct-2016 12:05 PM
Status:Open Resolved:
Product:Sample Code Product Version:Version 1.0, 2016-09-13
Classification:Serious Bug Reproducible:Yes
 
Summary:
The WatchBackgroundRefresh sample is intended to demonstrate background downloads using a URLSession downloadTask, but in practice the download does not ever complete.

Steps to Reproduce:
1. Download WatchBackgroundRefresh  sample code from https://developer.apple.com/library/prerelease/content/samplecode/WatchBackgroundRefresh/Introduction/Intro.html#//apple_ref/doc/uid/TP40017295
2. Open in Xcode and set the current target to WatchBackgroundRefresh WatchKit App
3. Build and Run in the iPhone and Watch simulators
4. Once the app has launched, tap the Schedule Refresh Button
5. Immediately type Command-Shift-H to simulate pressing the Digital Crown, sending the app into the background
6. Wait and monitor the Xcode console output


Expected Results:
After Step 4 the following line should appear on the console:

successfully scheduled background task, use the crown to send the app to the background and wait for handle:BackgroundTasks to fire.

After Step 5 the following lines should appear:

received background task:  <WKSnapshotRefreshBackgroundTask: 0x7b565410>
received background task:  <WKApplicationRefreshBackgroundTask: 0x7b36a980>
application task received, start URL session
Rejoining session <URLSession: 0xXXXXX>


Actual Results:
After Step 4 the following line appears as expected:

successfully scheduled background task, use the crown to send the app to the background and wait for handle:BackgroundTasks to fire.

After Step 5 the following lines appear:

received background task:  <WKSnapshotRefreshBackgroundTask: 0x7b565410>
received background task:  <WKApplicationRefreshBackgroundTask: 0x7b36a980>
application task received, start URL session

But we never see the line expected next:

Rejoining session <URLSession: 0xXXXXX>

Or indication that the download has completed. The app's Dock snapshot  is never updated.

Version:
WatchBackgroundRefresh  
 https://developer.apple.com/library/prerelease/content/samplecode/WatchBackgroundRefresh/Introduction/Intro.html#//apple_ref/doc/uid/TP40017295

Notes:


Configuration:
Mid-2012 Retina MacBook Pro

I failed to mention the most important part: I see these results with Xcode 8 (8A218a) and with Xcode 8.1b3 (8T47)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!