URL.startAccessingSecurityScopedResource() returns false for "On My iPad" after a while

My app allows to save user-selected URLs in a list and browse them with a tap. A user reported that the app often shows that when browsing their saved entry for "On My iPad", it's apparently empty (it contains no files).

I saved "On My iPad" in my own list some time ago and noticed that the same issue occurs. The URL seems to be correctly resolved from the saved bookmark data, but I noticed that url.startAccessingSecurityScopedResource() returns false. The other URL I saved some time ago is iCloud Drive, which I can access without issues. If I select "On My iPad" again in a file importer, create new bookmark data from it and resolve the URL from it, access works correctly.

I create bookmark data like this:

let data = try url.bookmarkData(includingResourceValuesForKeys: [.localizedNameKey, .pathKey, .volumeIsLocalKey])

and resolve URLs like this:

let url = try URL(resolvingBookmarkData: data, bookmarkDataIsStale: &bookmarkDataIsStale)

bookmarkDataIsStale is false for both the working and not working URLs for "On My iPad". The two bookmark data are different though, even if url.path is the same.

What could be the issue?

URL.startAccessingSecurityScopedResource() returns false for "On My iPad" after a while
 
 
Q