Creating file bookmarks doesn't work anymore on macOS 15 Sequoia

Before updating to macOS 15 Sequoia, I used to be able to create file bookmarks with this code:

let openPanel = NSOpenPanel()
openPanel.runModal()
let url = openPanel.urls[0]
do {
    let _ = try url.bookmarkData(options: [.withSecurityScope])
} catch {
    print(error)
}

Now I get an error

Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key"

These are the entitlements:

com.apple.security.app-sandbox
com.apple.security.files.user-selected.read-write
com.apple.security.files.bookmarks.app-scope

Strangely, my own apps continued working, after updating to macOS 15 some days ago, until a few moments ago. Then it seems that all of a sudden my existing bookmarks couldn't be resolved anymore, and no new bookmarks could be created. What could be the problem?

Answered by DTS Engineer in 806097022

Yesterday I filed FB15258541.

Thank you, that was very helpful.

What you're hitting is bug in "ScopedBookmarksAgent" which can cause it hang if it happens to have been launched when the keychain was also locked (for example, late in the screen lock process). That bug is fixed as of macOS 15.1 beta 4.

If you're hitting it regularly during development, you can resolve the issue by killing ScopedBookmarksAgent (you may also need to kill and relaunch your app, depending on what state it ends up). On the user side, a log out (or reboot) should resolve the issue.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Today, mysteriously, the sample code works again. How could this possibly happen? Yesterday all my App Store apps weren't able to resolve and create file bookmarks, and today they work again.

Today, mysteriously, the sample code works again. How could this possibly happen? Yesterday all my App Store apps weren't able to resolve and create file bookmarks, and today they work again.

It's hard to guess at an exact cause, but this particular error:

Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key"

...comes from one of the intermediate daemons involved in resolving security scoped bookmarks. If there was a problem in one of the lower level daemons it communicated with, then it's possible the problem would resolve itself if/when that daemon restarted.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

I have the same issue, did you find a solution?

I have the same issue, did you find a solution?

We're seeing the same thing in the wild. Security Scoped Bookmarks on macOS 15 don't resolve after a while.

Reports are that a device restart helps, but only for a little while. Trying to gather more data from some pretty angry users right now... Same app/binary works on lower macOS versions. App is a sandboxed.

Something is very broken resolving Security Scoped Bookmarks on Sequoia.

Edit to add: Same error is indicated (256).

Uh o. I have a sandbox app that uses security scoped bookmarks. Nobody's mentioned this to me so far.

Just to throw some spaghetti at the wall, is it possible this could be related to not balancing -startAccessingSecurityScopedResource calls with -stopAccessingSecurityScopedResource when you are done with the file?

If I remember from many years ago not doing this would eventually cause open/save panels etc. to no longer work in your app until after you reboot your Mac.

If you're having this kind of issue in your app, the first and most important step is to file bugs. If you've filed bugs, please post the bug numbers here.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Just to throw some spaghetti at the wall, is it possible this could be related to not balancing -startAccessingSecurityScopedResource calls with -stopAccessingSecurityScopedResource when you are done with the file?

I don't think so. This happened both with my App Store published app and with a sample app I had just created to reproduce the issue. Even after restarting both apps they had the same issue. It only disappeared the day after.

If you've filed bugs, please post the bug numbers here.

Yesterday I filed FB15258541.

Yesterday I filed FB15258541.

Thank you, that was very helpful.

What you're hitting is bug in "ScopedBookmarksAgent" which can cause it hang if it happens to have been launched when the keychain was also locked (for example, late in the screen lock process). That bug is fixed as of macOS 15.1 beta 4.

If you're hitting it regularly during development, you can resolve the issue by killing ScopedBookmarksAgent (you may also need to kill and relaunch your app, depending on what state it ends up). On the user side, a log out (or reboot) should resolve the issue.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

That bug is fixed as of macOS 15.1 beta 4.

Thank you for the feedback. I'm looking forward to the fix.

Thanks for the quick fix. Also running into this and can't wait for 15.1 to come out!

Does anyone see the same problem on macOS 14.7.1?

I've received multiple reports from users that macOS 14.7.1 cannot create new bookmarks or resolve existing bookmarks. Same error message:

Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key" UserInfo={NSDebugDescription=Failed to retrieve app-scope key}
  • All users updated from macOS 13.* Ventura to macOS 14.7.1 Sonoma, which triggered the issue
  • Restarting Mac does not fix the issue
  • Clearing all app data does not resolve the issue

One user reported that using bookmarks on a new macOS user account works correctly. This leads me to believe that the macOS keychain for their user account is broken. See also https://developer.apple.com/forums/thread/46583

Does upgrading from macOS 13 to macOS 14.7.1 break the keychain?

Still seeing this issue on 15.1. Also on 14.5 and 14.6.

I haven't had the issue since updating to macOS 15.1 and haven't got any more reports from users either, but I will update you if I do.

I haven't had the issue since updating to macOS 15.1 and haven't got any more reports from users either, but I will update you if I do.

If this happens on macOS 15.1 or later, then please file a new bug create and create a new thread or post the bug number back here (if this happens "soon").

One thing to be aware of here is that a system component like this has a very straightforward API surface (give URL-> get Data) with a very complex underlying implementation (multiple daemons, framework layer, sandboxing, file system issues, etc.). That dynamic means that there's a huge variety of possible failure points... of which look exactly the same at the final API layer ("my bookmark doesn't work").

That makes new bugs particular important because you want to make sure the issue gets investigated quickly by highlighting exactly where/how/when the failure is occur ("15.1, SMB volume, on Tuesdays") and by ensuring that the investigation starts from a "clean" slate, not with the team which happened to be responsible for the previous issue.

The new thread is just a miniature version of the same dynamic, as I can't promise I won't miss an update on this thread if it happens a year from now 🙂.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

I've received multiple reports from users that macOS 14.7.1 cannot create new bookmarks or resolve existing bookmarks.

Today I too was contacted by a user who updated from macOS 13 to 14.7.1 and was quite desperate since my app couldn't resolve or create bookmarks anymore. Restarting the Mac didn't help. Thankfully you already reported the same issue so I suggested to update to 15.1.1, which finally solved the issue.

Today I too was contacted by a user who updated from macOS 13 to 14.7.1 and was quite desperate since my app couldn't resolve or create bookmarks anymore. Restarting the Mac didn't help. Thankfully you already reported the same issue so I suggested to update to 15.1.1, which finally solved the issue.

So far it only seems to happen for users that update from macOS 13. Very strange!

I've received multiple confirmations that any of these solutions resolve the issue:

  • Create a new user account (old account will stay bugged)
  • Reset the macOS keychain for the (bugged) user account
  • Update to 15.1+

Resetting the keychain is a bit technical and may cause data loss, so I recommend users to contact Apple Support for help with that.

I've received multiple confirmations that any of these solutions resolve the issue:

  • Create a new user account (old account will stay bugged)

  • Reset the macOS keychain for the (bugged) user account

  • Update to 15.1+

Thank you SO MUCH for this.

I've spent a TON of time investigating why, after updating from Ventura to Sonoma, Final Cut Pro 11 was being so terribly SLOW ( mainly when opening libraries and when closing the app ), even though FCP 10.8.1 worked fine! A clue pointing me towards this thread popped up, when I tried to use HandBrake to transcode a video and have encountered the very same problems as in FCP.

Handbrake's console listed the following:

[09:30:49] macgui: Failed to create bookmark: Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key" UserInfo={NSDebugDescription=Failed to retrieve app-scope key}

[09:30:49] macgui: Failed to create bookmark: Error Domain=NSCocoaErrorDomain Code=256 "Could not open() the item" UserInfo={NSURL=file:///Users/######/Library/Containers/fr.handbrake.HandBrake/Data/Movies/, NSDebugDescription=Could not open() the item}

The new user account also worked flawlessly but that was obviously not a solution.

Nothing I did helped ( and believe you me, I've tried a ton of stuff, from re-downloading the app via app store, through launching it via a sandbox, rosetta, changing the permissions, ownership, flags, permissions via tccutil etc. to changing the user password, Mac's name and so on ) until I have resetted the macOS keychain.

So if anybody else's looking for solution to apps suddenly being weirdly slow when f.ex opening files and/or when closing, this is it.

Does upgrading from macOS 13 to macOS 14.7.1 break the keychain?

Apparently so. I didn't do anything in particular when updating. I do recall that Software Update popped up an update for some XCode's tools - a version 1.0 and 1.1 - and I've installed only 1.1 though I'm not sure if this has anything to do with this.

In any case, thanks again!

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

I've received multiple reports from users that macOS 14.7.1 cannot create new bookmarks or resolve existing bookmarks.

This is a known issue (r.140342863). In terms of diagnosing the issue, you'll see these two log messages from ScopedBookmarkAgent shortly before it exits:

ScopedBookmarkAgent: [com.apple.FileURL:scoped] copy_data_protection_agent_key: error -25300 fetching key for UID...

ScopedBookmarkAgent: [com.apple.FileURL:scoped] copy_migrated_agent_key: error inserting the agent key: -25299

I can't provide any specific information about if/when it will be fixed, but this is being treated as a very serious issue, given how critical the keychain is to the system.

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

This is a totally different issue. I don't know what the specific issue might be, but these two elements:

  1. The app is running for a significant period of time.

  2. The app works fine after it's quit relaunched.

...typically indicate that there's an issue with how scoped bookmarks are being managed. Each scoped bookmark your app has "active" requires a corresponding in kernel resource and once your app reaches that limit, scoped resolution will stop working.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

The app is running for a significant period of time.

I had launched the app at most a couple hours earlier. I had the app running for weeks before and never had this issue.

I had launched the app at most a couple hours earlier. I had the app running for weeks before and never had this issue.

OK. To clarify what I was said above, I'm not saying there isn't a system bug involved, as it's certainly possible there is one. What I'm saying is that whatever is going on doesn't sound like the same issue that this thread is about.

In terms of investigating your failure, I would probably do the following:

  1. Add logging to your app immediately before and immediately after the function call where you detect the failure, making sure those messages reach the console log.

  2. Test your app normally until the failure occurs again.

  3. After the failure occurs, trigger a sysdiagnose.

  4. Open the console log from the sysdiagnose and find the two logs messages your app printed for the failure (#1 above).

  5. Look at the system console messages between those two points and "see what happened".

However, if you find something you want help with, please post it as a new forum thread.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Another macOS 14.7.2 user contacted me with this issue. Angry that my app isn't "compatible with macOS". I told them to contact Apple support, but they just wouldn't listen. Anyway not sure if that would have helped, as Apple support usually tells people that they should contact the third party developer. Then, with two conflicting answers, the user believes that I refuse to help them.

Does nobody at Apple see how frustrating this is for us developers? Is there nothing you can do to mitigate the anger our users have towards us because of issues in your operating system? People apparently are more inclined to believe that the small third party developer is at fault. I even sent them a link to this topic to convince them that it's a known macOS issue, but not sure if they visited it or could even understand it. Would it be too much to ask for Apple to make public announcements about these issues that normal users can understand and that we can point them to when they direct their anger towards us?

Following up on this thread, I believe the final bugs around this issue are resolved in the following security updates:

macOS Sonoma  14.7.3 (23H417)
macOS Ventura 13.7.3 (22H417)

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Creating file bookmarks doesn't work anymore on macOS 15 Sequoia
 
 
Q