Unexpected Core Spotlight / NSUserActivity deduping behavior

Originator:bogo.giertler
Number:rdar://22212032 Date Originated:08/10/2015
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 9 beta 5
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
For an NSUserActivity to be indexed, it needs to have a matching Core Spotlight entry already in the index. However, it seems that user activities are not indexed until both userInfo and requiredUserInfoKeys are set, even with arbitrary values. Without these set, a duplicated item will appear in the search results, with no userInfo provided in application:continueUserActivity:restorationHandler, making it impossible for application to consume the result. (thus the data loss)

Steps to Reproduce:
 - Attempt to create a user activity *after* successful indexing item matching the user activity.
 - Make the user activity's relatedUniqueIdenitifier point to a valid UID. (do not set either userInfo or requiredUserInfoKeys)
 - Make the activity current and leave the application.
 - Attempt to search for the activity.

(attached AppDelegate.m, lines 74-75 show the example of such situation, prune your index and comment line 75 to observe the actual behavior.)

Expected Results:
The Spotlight results shows one result

Actual Results:
The Spotlight results show two results.

Version:
iOS 9 beta 5

Configuration:
iPad Air 2, iOS Simulator

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!