First launch of watchOS2 apps fails when opening from a notification

Originator:jrturton
Number:rdar://25214443 Date Originated:17-Mar-2016 10:48 AM
Status:Open Resolved:
Product:iOS Product Version:9.2 / watchOS 2.1
Classification:Serious Bug Reproducible:Always
 
Summary:
If a watch app has never been launched or is not in memory, and a local notification arrives, if the notification is tapped too quickly (< ~3 seconds) then the app either fails to launch (sticks on the loading spinner) or finally launches with unresponsive UI. If the app is stuck on the loading spinner, switching to the watch face and back to the app gives you unresponsive UI. 

If the user waits longer before tapping the notification, the watch app opens normally.

Steps to Reproduce:

1. Install the sample project (the iOS app scheme) on an iPhone which is paired to a watch. Don’t launch the watch app from Xcode. Using the Watch app on the phone, install the watch app. 
2. Open the sample app on the phone, hit the button, then sleep the iPhone. This schedules a local notification to arrive in 5 seconds time.
3. Wait for the paired watch to display the notification
4. Tap the notification as soon as the interface allows
5. Observe that the app fails to launch, or launches with unresponsive UI
6. If you are stuck on the spinner, switch back to the watch face then into the app again and observe the unresponsive UI. 
7. Delete the app from the watch
8. On the Watch app on the iPhone, reinstall the watch app
9. Open the iPhone app, hit the button and sleep the iPhone
10. Observe the notification arriving on the watch. Wait for >5 seconds before tapping it
11. Observe that the application opens correctly and the UI is responsive

Expected Results:

I expect the watch app to launch successfully in all cases

Actual Results:

The watch app does not launch if the notification is tapped too quickly

Regression:

This only seems to occur on first launch. Subsequent launches are fine. 

Notes:

A sample project demonstrating the issue is attached. Looking at logging from the watch (which is difficult, since that seems to affect the problem) it appears to fail when 

xxxxx.watchkitextension is now running in the foreground

is not logged before 

Got notification URL. Will pass notification ID …

You see several messages in the failure states, but one of them we see all the time is

<Notice>: (Error) WatchKit: <SPRemoteInterface.m -[SPRemoteInterface _handleAction:forNotification:remoteNotificationContext:localNotification:handler:controller:]:2863> called but remoteNotification and localNotification are both nil. This shouldn't have happened

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!