-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui] Thumbnail cache #1861
[ui] Thumbnail cache #1861
Conversation
Tested loading on windows with jpg datasets from 16 to 1000 images, loading seems to work. |
After some investigation it seems that this is not related to this PR. More specifically the problem is that for large image datasets (noticed on datasets with 1000 images) the "Clear Image" action will freeze the app. |
Remark: |
Actually now thumbnail creation is asynchronous so the app doesn't block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change default path for meshroom cache and some minor improvements.
This is so we can control in which order the requests are handled, as we want LIFO ordering instead of FIFO for smoother interaction.
As we rely on the thumbnails cache, the images are already downscaled at a small resolution. So there is no more need to force a max resolution on the Qml Image.
Description
This PR introduces a new caching mechanism for thumbnails to improve interactivity when navigating in the Image Gallery.
This cache associates to each image a unique thumbnail, which is stored on disk for later reuse.
Cache directory
The storing location is global (i.e not specific to a Meshroom scene).
The default location can be overriden with the
MESHROOM_THUMBNAIL_DIR
environment variable.The thumbnails dimensions cannot exceed 256x256, and are stored on disk in JPEG format.
On the tested dataset, their size vary between 6 and 11 Ko (per thumbnail).
Automatic cleaning process
When launching the application, the cache directory is scanned and all thumbnails that haven't been used for more than a certain time limit are removed. This process also makes sure that the number of thumbnails on disk does not exceed a certain limit.
The default time limit is 90 days, and can be overriden with the
MESHROOM_THUMBNAIL_TIME_LIMIT
environment variable.The default maximum number of thumbnails on disk is 100000, and can be overriden with the
MESHROOM_MAX_THUMBNAILS_ON_DISK
environment variable.Asynchronous thumbnail creation
Since thumbnail creation can be quite long on large image datasets it is performed asynchronously (using 3 worker threads) to avoid blocking the UI.
A loading circle is displayed during the thumbnail creation process to let the user know that computations are undergoing.
When a thumbnail is created, a signal is sent to the Image Gallery, and the grid view is in charge of dispatching it to the corresponding Image Delegate.
Details on thumbnail creation requests
Thumbnail creation requests are stored in a LIFO (last-in-first-out) structure: this way, when scrolling through the image gallery, the items that the user is currently viewing have priority in the calculations.
Also, to avoid situations in which thumbnails are never retrieved, a timer is used to re-send some requests every 2 seconds if needed.
Finally, all requests are cleared when the viewpoints change. This way, when changing the scene, if thumbnail calculations of the previous scene are not finished (which can happen if the image dataset is quite large), they won't slow done calculations of the current scene.
Tests
Tested on Windows and Linux, using images with different formats (JPEG, EXR, RAW), aspect ratio and Exif orientation tags.
Tested varying the storage time limit and maximum number of thumbnails on disk.
Tested with existing and non-existing thumbnail directory (in the second case, the directory is created recursively).
Stress tested on a 12000 high resolution images dataset and compared to current develop branch to check that fluidity has improved.