When Recent Items vanish: a possible bug in Sierra 10.12.6?

A couple of times just recently, I think since the Sierra 10.12.6 update, the system service which supplies Recent Items has played up. I’m wondering whether this is a bug new to 10.12.6, or maybe I have just been unlucky.

I first noticed it in Xcode. When launched, it has a splash screen on which it lists those projects which have been opened recently – the same as are listed in the Open Recent… command in its File menu. All of a sudden, Xcode told me that no projects had been opened recently, both on that splash screen and in its empty Open Recent… item.

Most other apps were the same. GraphicConverter 10, for example, which I use daily to prepare images for this blog, swore blind that I had never opened an image with it before. BBEdit was different, though, as it maintains its own custom Recent Items scheme, which was unaffected.

I then looked in the other place that offers Recent Items: that command in the Apple menu. Here the problem was the exact opposite: apps and documents were listed multiple times, apparently for every occasion that I had opened them over the last week or so.



The solution was obvious: in the General pane in System Preferences, the Recent items setting had gone wonky. When I opened that pane, it certainly had, as it was set to None. I set it back to 10, closed System Preferences, and checked again. It had been returned to None.


So it was a preferences problem after all. I presumed that this would be stored in com.apple.finder.plist or similar, so watched which of the files changed when I altered that setting in the General pane. The suspects were com.apple.finder.plist and com.apple.systempreferences.plist, so I made copies and looked through them in BBEdit.

Neither property list contains any key vaguely resembling a control over the number of recent items.

It then occurred to me that I could search for the setting using the command defaults, with
defaults find recent
which returned nothing of any relevance.

It was time to take to the developer documentation, to see if Apple describes how the Recent Items feature works.

In apps, the Open Recent menu command is handled by NSDocumentController, which has a suite of five items for its management, including the variable recentDocumentURLs, which contains a list of recent document URLs. You can programmatically inspect the maximum item count, in the variable maximumRecentDocumentCount, an Int, for which Apple helpfully explains:
The default implementation returns a value that is subject to change and may or may not be derived from a setting made by the user in System Preferences.
I like the “may or may not”, that’s just so specific.

So where are these lists of recent items kept? There were only two likely folders: ~/Library/Preferences, which would have been the logical place to store them I think, and ~/Library/Application Support/com.apple.sharedfilelist. The latter folder contains a hierarchy of .sfl files which are in fact just property lists in sheep’s clothing.

Among them, com.apple.LSSharedFileList.RecentDocuments.sfl and com.apple.LSSharedFileList.ApplicationRecentDocuments.sfl both contained the key-value pair
in spite of the setting in System Preferences, the weird behaviour of the Finder’s Recent Items command, and those in individual apps.

Suspecting now that Recent Items is provided not simply by a preference setting and some property lists, and armed with the magic word fragment LSShared, I looked through Activity Monitor’s list of active processes. There were two instances of a process named lsd, one for me and one for root. Could this be the LS daemon, providing Launch Services including Recent Items?

I don’t know. Opening the man page for lsd in Dash revealed another gem of information from our friends in Apple:
lsd provides various services for CoreServices frameworks. It is not meant to be invoked directly and it must not be terminated.
But in its documentation for Launch Services, Apple does mention in passing that they are now responsible for maintaining the Recent Items lists used in apps and the Finder.

Has anyone else suffered similar problems in Sierra? Have your Recent Items mysteriously vanished since updating to 10.12.6? I’d be fascinated to know.

Oh – and the solution to my original problem? I restarted, following which the Recent Items item in the General pane was back to 10 again. Let’s hope it stays that way.