question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asynchronous Folder Thumbnailing

See original GitHub issue

At the moment non-cached folder thumbnails are not received asynchronously, but rather a single database query is sent for every single folder synchronously, and only then the directory listing (gallery) is eventually built when everything else is already available. Therefore the availability of the directory listing (gallery) itself is delayed until a thumbnail was received for every single folder, which can result in the whole application becoming unavailable while these queries are running on particularly large folders or subfolders. (tested 700 subfolders, takes minutes!)

It would be better to initially build the directory listing (gallery) with blank folder thumbnails for it to become available fast, which are then filled in with actual folder thumbnails asynchronously, like it is already done when viewing folders containing only images (not subfolders/subfolders & images). Like for images, there should also be an option that only folder thumbnails are received for the immediate visible folders (lazy image rendering)

This is what is currently happening BEFORE the directory listing is built (with the loading bar filling on top of the page):

query: SELECT "media"."id" AS "media_id", "media"."name" AS "media_name", "directory"."name" AS "directory_name", "directory"."path" AS "directory_path", "directory"."id" AS "directory_id" FROM "media_entity" "media" INNER JOIN "directory_entity" "directory" ON "directory"."id"="media"."directoryId" WHERE ("media"."directoryId" = ? OR "directory"."path" GLOB ?) ORDER BY LENGTH("directory"."path") DESC, "media"."metadataRating" DESC, "media"."metadataCreationdate" DESC LIMIT 1 -- PARAMETERS: [3380,"Dir1/*"]

query: SELECT "media"."id" AS "media_id", "media"."name" AS "media_name", "directory"."name" AS "directory_name", "directory"."path" AS "directory_path", "directory"."id" AS "directory_id" FROM "media_entity" "media" INNER JOIN "directory_entity" "directory" ON "directory"."id"="media"."directoryId" WHERE ("media"."directoryId" = ? OR "directory"."path" GLOB ?) ORDER BY LENGTH("directory"."path") DESC, "media"."metadataRating" DESC, "media"."metadataCreationdate" DESC LIMIT 1 -- PARAMETERS: [3381,"Dir2/*"]

[…] x number of subfolders in navigated directory

I, therefore, propose the directory listing (gallery) is built immediately with blank folder thumbnails, which are then exchanged for actual folder thumbnails with the above queries running asynchronously in the background. The unfinished queries should also be cleared from the asynchronous queue when the user navigates away from the folder before all thumbnails were built, instead of continuing to run in the background and eat up database resources (as it is currently happening).

P.S. I have tested this on a project with all folders pre-indexed and pre-thumbnailed on an SSD, so there should be no further bottlenecks apart from these synchronous thumbnailing queries.

P.P.S I have run further testing and can confirm that these queries, receiving the folder thumbnails from the database, are the bottleneck here. If I let the particular function return “null” on every requested folder thumbnail, the directory listing becomes available instantly with blank thumbnails even on folders with 700+ subfolders.

This might also be relevant for #299

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
bpatrikcommented, Jan 14, 2022

776c8e8 introduces a column to store the directory previews. This should speed up the listing. (not first time ever listing will be still slow. assigning preview is lazy. They are assigned only when they are needed)

1reaction
bpatrikcommented, Jan 15, 2022

nightly should have it already

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run more than one thumbnailer processes at a time (#1397)
Use cases. When viewing folders with many images or videos, thumbnail generation seems to progress in a synchronous fashion.
Read more >
winforms - How to use Async to create files and thumbnails?
Quite simply I create a file on the file system and then immediately create a thumbnail image if the file is an image...
Read more >
Creating Quick Look Thumbnails to Preview Files in Your App
Generate thumbnails of images, text files, PDFs, audio files, videos, and more. ... It provides asynchronous methods for three common use cases:.
Read more >
Mediamoose / Async thumbnail · GitLab
Offload sorl thumbnail rendering to a render view. ... An error occurred while fetching folder content. A. Async thumbnail. Project ID: 9908819.
Read more >
Create Thumbnails Concurrently in Python (3x faster)
How to create thumbnail images one by one in Python and how slow it ... Unzip the archive and select a folder of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found