Fix #106023: File Browser Lists with Incomplete Previews #107698

Merged
Harley Acheson merged 3 commits from Harley/blender:ListPreviews into main 2023-05-08 20:53:14 +02:00
Member

Ensure all File Browser list items get previews.


When we start creating a preview for a File Browser item we give it a FILE_ENTRY_PREVIEW_LOADING bit flag and we remove it when complete. This is done to make sure that multiple threads don't work on the same preview at the same time.

However there are MANY times when we clear the preview cache (filelist_cache_previews_clear) for a variety of reasons. When this happens any items that were in the cache queue retain their FILE_ENTRY_PREVIEW_LOADING flag. This means they won't be previewed if we try to add them to the queue again. This results in two types of bad behavior. The first is that given a list of items that have never been previewed, if you scroll while these are being created there might be some items that are never done and will remain showing a generic image icon. The second problem is if a folder contains more items than the cache size (usually 255 items) you might see some generic icons on either end of the list even if all items have been previewed.

This PR just checks for the state of a cleared cache (cache->previews_todo_count == 0) at the point of adding new items to the queue. If this is the case we remove that FILE_ENTRY_PREVIEW_LOADING bit flag since there is no good reason for it to be there at that time; it will only be there in error because the cache was cleared while it was in there.

Ensure all File Browser list items get previews. --- When we start creating a preview for a File Browser item we give it a FILE_ENTRY_PREVIEW_LOADING bit flag and we remove it when complete. This is done to make sure that multiple threads don't work on the same preview at the same time. However there are MANY times when we clear the preview cache (filelist_cache_previews_clear) for a variety of reasons. When this happens any items that were in the cache queue retain their FILE_ENTRY_PREVIEW_LOADING flag. This means they won't be previewed if we try to add them to the queue again. This results in two types of bad behavior. The first is that given a list of items that have never been previewed, if you scroll while these are being created there might be some items that are never done and will remain showing a generic image icon. The second problem is if a folder contains more items than the cache size (usually 255 items) you might see some generic icons on either end of the list even if all items have been previewed. This PR just checks for the state of a cleared cache (cache->previews_todo_count == 0) at the point of adding new items to the queue. If this is the case we remove that FILE_ENTRY_PREVIEW_LOADING bit flag since there is no good reason for it to be there at that time; it will only be there in error because the cache was cleared while it was in there.
Harley Acheson added 1 commit 2023-05-07 03:52:56 +02:00
31af641f82 Fix #106023: File Browser Lists with Incomplete Previews
Ensure all File Browser list items get previews.
Harley Acheson added this to the User Interface project 2023-05-07 03:53:10 +02:00
Harley Acheson requested review from Julian Eisel 2023-05-07 03:53:16 +02:00

I can confirm this PR does seem to fix the issue for my case. I was going to suggest that the flag be removed inside filelist_cache_previews_clear rather than where you did here, since that would make the most sense, but I don't see a way to do that?

I can confirm this PR does seem to fix the issue for my case. I was going to suggest that the flag be removed inside `filelist_cache_previews_clear` rather than where you did here, since that would make the most sense, but I don't see a way to do that?
Author
Member

...suggest that the flag be removed inside `filelist_cache_previews_clear...I don't see a way to do that?

Yeah, me neither. I also looked at that and couldn't see a nice way to do this there while this PR is simple even if a little removed from the problem.

I also found a wonderful performance improvement if filelist_file_cache_slidingwindow_set is not allowed to make filelist_cache.size go below the initial value of FILELIST_ENTRYCACHESIZE_DEFAULT (1024). Mine is normally at 256 even though the intention is that it be between 256-8092. I'll probably post a PR for that but still thinking of how to sell it.

> ...suggest that the flag be removed inside `filelist_cache_previews_clear...I don't see a way to do that? Yeah, me neither. I also looked at that and couldn't see a nice way to do this there while this PR is simple even if a little removed from the problem. I also found a wonderful performance improvement if `filelist_file_cache_slidingwindow_set` is not allowed to make `filelist_cache.size` go below the initial value of FILELIST_ENTRYCACHESIZE_DEFAULT (1024). Mine is normally at 256 even though the intention is that it be between 256-8092. I'll probably post a PR for that but still thinking of how to sell it.
Member

This is indeed a quite random place to put this in, and I'm not sure how reliable it is.

This should be better:

diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index c5ff4ea30e6..7c1e2c32d79 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -1552,6 +1552,10 @@ static void filelist_cache_previews_clear(FileListEntryCache *cache)
   if (cache->previews_pool) {
     BLI_task_pool_cancel(cache->previews_pool);
 
+    LISTBASE_FOREACH (FileDirEntry *, entry, &cache->cached_entries) {
+      entry->flags &= ~FILE_ENTRY_PREVIEW_LOADING;
+    }
+
     FileListEntryPreview *preview;
     while ((preview = static_cast<FileListEntryPreview *>(
                 BLI_thread_queue_pop_timeout(cache->previews_done, 0))))

This is indeed a quite random place to put this in, and I'm not sure how reliable it is. This should be better: ```diff diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index c5ff4ea30e6..7c1e2c32d79 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -1552,6 +1552,10 @@ static void filelist_cache_previews_clear(FileListEntryCache *cache) if (cache->previews_pool) { BLI_task_pool_cancel(cache->previews_pool); + LISTBASE_FOREACH (FileDirEntry *, entry, &cache->cached_entries) { + entry->flags &= ~FILE_ENTRY_PREVIEW_LOADING; + } + FileListEntryPreview *preview; while ((preview = static_cast<FileListEntryPreview *>( BLI_thread_queue_pop_timeout(cache->previews_done, 0)))) ```
Harley Acheson added 1 commit 2023-05-08 19:17:49 +02:00
Author
Member

@JulianEisel - ...random place to put this...This should be better

Yes, a much better place to do this. Tested again, works great.

> @JulianEisel - ...random place to put this...This should be better Yes, a much better place to do this. Tested again, works great.
Julian Eisel approved these changes 2023-05-08 19:34:47 +02:00
Harley Acheson added 1 commit 2023-05-08 19:44:48 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
75d9c241c7
Merge branch 'main' into ListPreviews
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson merged commit 8e4e616a4b into main 2023-05-08 20:53:14 +02:00
Harley Acheson deleted branch ListPreviews 2023-05-08 20:53:17 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:41 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107698
No description provided.