Thumbnails are shuffling around / resorting while loading large folders in grid view
Affected version
- Nightly flatpak: Yes (as of 2023-08-21)
- Other: 44.1, 44.0, 43.2, and any previous version in the last few years
Steps to reproduce
- Set Nautilus to grid view (it is easier to notice the problem than in listview mode)
- Visit a folder containing a couple hundreds of thumbnailed video files (image files), ideally in a different sorting order than when they were originally thumbnailed
Current behavior
As you can see in this demonstration video, with 670 media files in a folder: https://youtu.be/4yIX-Tj94lc
...thumbnails "shuffle" around very visibly while the folder gets loaded, instead of appearing in the order the files are in.
Expected behavior
No mahjong thumbnail shuffling at all
Measurements
Here are my Sysprof captures:
- Sysprof capture of version 43.2 on Fedora 37:
Nautilus 43.2 shuffling thumbnails sysprof - Better sysprof capture with version 44.0 on Fedora 38 (which would have frame pointers):
Nautilus 44.0 shuffling thumbnails sysprof - Even better sysprof capture with version 44.1 on Fedora 38 on Wayland, including every measurement possible by Sysprof, and with debuginfo packages installed for glib2, gtk4 and nautilus: Nautilus 44.1 shuffling thumbnails sysprof with all debuginfo
(Note: this one is measured on my desktop computer with triple-buffering Mutter patches from this package repository, ensuring the graphics stack is blazing fast on my computer, just to rule that out of the equation)
It looks roughly like this on version 44.0:
...and here's version 44.1 on Wayland (with triple-buffering Mutter performance patches applied), and debuginfo packages installed for glib2, gtk4 and nautilus (in multiple parts, because the sysprof output is way too tall to provide a usable single screenshot here):
Additional information
This occurs particularly on the 1st load of those media-heavy folders on a fresh launch of Nautilus, but subsequent (re)loads of the same folder in the same Nautilus session (i.e. without ending the running Nautilus process) are faster / fast enough that the problem is much less noticeable.
I have observed this no matter the sort order (whether sorting by Size, Last Modified, "A -> Z" alphabetical, etc.).
I'm suspecting that, in addition to being visually annoying (which turns out to be an accessibility problem for motion-sensitive people), this is probably a performance issue, as certainly this massive shuffling must have a noticeable impact by spamming all the rest of the GUI with requests and repainting.
It might have something to do with the sorting order being different between when the thumbnails were generated vs when they are displayed, but I don't see how that would cause this problem, because XDG thumbnail filenames are MD5 hashes of the corresponding media files' absolute URIs... they don't have a time component, as far as I understand.
The GTK 4.10.x FileChooser's thumbnails gridview is not affected by this issue, it paints the whole folder in a single pass.
Hardware info
This problem might manifest itself more clearly on computers that use traditional hard drives (rather than solid state drives) to hold their large data collections, but it also happens on much faster computers with SSDs. Note, however, that my XDG thumbnails cache folder (.cache/thumbnails
) is actually a symlink pointing to my small SSD, so technically the thumbnails folder is super fast, not limited by the HDD's seek latency. The actual video files (that the thumbnails are referring to), however, are on the HDD.
On my primary desktop computer, I am running open source AMD Radeon R9 270 graphics on Xorg/X11... but I've seen it happen not only on my desktop computer, but also an overpowered HP Spectre laptop (Intel Kabylake 8th generation Core i7 with NVMe SSD and Intel graphics running on Wayland)