Asset System & UI: Improve memory management for assets and previews #111614
Labels
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111614
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Loading asset libraries can lead to significant memory use, since all contained assets need to be represented in memory. This may be thousands of assets. Further, the UI may request previews for assets, where each preview has a notable memory footprint (around 70kB for each preview at the default 256x256 image size).
As it stands, Blender is not mindful about this at all. For example simply calling the "Add" menu in geometry nodes editors loads all asset libraries into memory (!), including all previews (!) and keeps all this data in memory until another .blend is read (!). This is bad and wasteful design that users have to pay for.
Status Quo
Memory and asset lifetime is managed rather differently in the asset browser and the rest of the UI (asset shelves, add menus, etc.).
Current Asset Browser Memory Management:
The situation for the asset browser is not too bad (because it's simpler).
Rest of the UI:
(Asset views, the node add menu, the node search menu, asset-view template, etc.)
How to solve it?
Good solution characteristics
A good solution should give us the following:
(Further improvements are possible still, see below)
Lazy Loading Previews
Previews should always be lazy loaded based on which assets the user sees, and only if the previews are actually displayed (e.g. not for the node "Add" menu). #109234 does most of the necessary work for this.
Garbage Collector?
A garbage collector could be implemented to remove unused asset libraries and asset previews from storage. Some kind of user-counting will be needed to detect the unused state, even when multiple parts of the UI display the same asset library (and thus may share storage). By being time based rather than user-count based only, the garbage collector still gives enough time for repetitive access to asset libraries. For example the asset library may still be in storage for multiple calls to the node "Add" menu, but be freed from storage if it hasn't been called for at least 5 minutes.
Note that this doesn't need to be asset system specific. There are other UI previews that we load from disk that could make use of this. So this could be a more general UI garbage collector.
Possible Further Improvements
Partial asset library loading?
Users rarely ever look at all assets of a library. They typically look at assets of a certain type (e.g. in the node "Add" menu), a specific catalog, or the view simply only has space for a subset of the available assets. So this is another case where we can avoid keeping data in storage, e.g. by lazy loading assets or deleting them once they are recognized as irrelevant.
Keeping track of which assets are loaded and which have to be made available can be finicky. Plus we may run into issues when asset library contents were updated in-between partial reads.
Lazy load extended metadata
In most cases, all the user sees from an asset is the name, and potentially the preview. Keeping all the asset metadata in storage is a bit of a waste. We could lazy load this as well, although this can become finicky too, since some metadata needs to be accessed faster or more frequently (e.g. basic type information, tags for search, etc.) than other.
Compressed preview buffers
Preview buffers could be compressed to reduce the memory footprint of each, potentially leading to faster load times too.