Thumbnail images in iOS / iPadOS slow to update

Question asked during the 6-6-23 UIKit Q&A Slack session of WWDC 2023

My iOS / iPadOS / Catalyst app has a thumbnail extension with a QLThumbnailProvider subclass that implements the provideThumbnail(for:_:) method providing the thumbnail for a document created in my app, by drawing the thumbnail image into the current context. That implementation successfully updates the thumbnail for the document, but sometimes the thumbnail's displayed image (in, for instance, the Files app or my app's own UIDocumentBrowserViewController on iPhone or iPad) is slow to update. (This update slowness seems especially to be a problem for documents stored in iCloud Drive, rather than in local storage.)

(1) Am I correct in presuming that the displayed thumbnail images are cached somewhere, and the reason the displayed thumbnail images are slow to update is because either (a) the thumbnail cache is slow to update and/or (b) the system only periodically calls the provideThumbnail(for:_:) method?

(2) If so, is there some way my app can either (a) force the thumbnail image cache to update more quickly and/or (b) force the provideThumbnail(for:_:) method to be called, so that the displayed thumbnail images for the created/modified documents are quicker to update?

(I asked this question during the WWDC Slack session mentioned, but the Apple moderators said at the time, "We don’t have the right expert available to answer this. Please ask on https://developer.apple.com/forums/ .")

Hello,

Yes, there is a thumbnail cache, but the cache is based on the version of the file (based on either file size, modification time, or item contentVersion for File Provider items), so in theory there is nothing you should do, and your provideThumbnail should be called again whenever the system needs a thumbnail for the file and it determines the file was modified since the last time a thumbnail was cached. At this point you should probably file a Feedback. Please install the iCloud Drive logging profile from https://developer.apple.com/bug-reporting/profiles-and-logs (which also enables detailed Quick Look logs). Provide a sysdiagnose, the file name and the timestamp at which you would expect provideThumbnail to be called (if it doesn't get called at that point). Thank you!

(Is your file format a package? If so please make sure you safe-save your documents properly, or the mtime of the package root won't update)

Thumbnail images in iOS / iPadOS slow to update
 
 
Q