Fix #104305: Crash in node editor with large asset libraries #105773

Closed
Julian Eisel wants to merge 5 commits from JulianEisel:temp-fix-volatile-asset-handle into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Various UI code would store the AssetHandle in a way that turns out to be
unsafe. The file-data is part of the file browser caching system that releases
file-data when a certain maximum of items is in the cache. So even while just
iterating over the assets, earlier iterated asset handles may become invalid.
Now asset handles are really treated as volatile, short lived objects.

For the asset-view, the fix was more involved. There we need an RNA collection
of asset-handles, because the UI list code requires that. So we create a dummy
collection and get the asset handles as needed by index. This again meant that
I had to keep the index of the collection and the asset-list in sync, so all
filtering had to be moved to the UI list.
I tried duplicating the file-data out of the cache instead, but that caused
problems with managing the memory/ownership of the preview images.

AssetHandle should be removed and replaced by AssetRepresentation, but this
would be an even more disruptive change (breaking API compatibility too).

Fixes #104305, #105535.

Various UI code would store the `AssetHandle` in a way that turns out to be unsafe. The file-data is part of the file browser caching system that releases file-data when a certain maximum of items is in the cache. So even while just iterating over the assets, earlier iterated asset handles may become invalid. Now asset handles are really treated as volatile, short lived objects. For the asset-view, the fix was more involved. There we need an RNA collection of asset-handles, because the UI list code requires that. So we create a dummy collection and get the asset handles as needed by index. This again meant that I had to keep the index of the collection and the asset-list in sync, so all filtering had to be moved to the UI list. I tried duplicating the file-data out of the cache instead, but that caused problems with managing the memory/ownership of the preview images. `AssetHandle` should be removed and replaced by `AssetRepresentation`, but this would be an even more disruptive change (breaking API compatibility too). Fixes #104305, #105535.
Julian Eisel added 1 commit 2023-03-14 19:02:32 +01:00
c0ff16a6f7 Fix 104305: Crash in node editor with large asset libraries
Various UI code would store the `AssetHandle` in a way that turns out to
be unsafe. The file-data is part of the file browser caching system that
releases file-data when a certain maximum of items is in the cache. So
even while just iterating over the assets, earlier iterated asset
handles may become invalid. Some

For the asset-view, the fix was more involved. There we need an RNA
collection of asset-handles, because the UI list code requires that. So
we create a dummy collection and get the asset handles as needed by
index. This again meant that I had to keep the index of the collection
and the asset-list in sync, so all filtering had to be moved to the UI
list.
I tried duplicating the file-data out of the cache instead, but that
caused problems with managing the memory/ownership of the preview
images.

`AssetHandle` should be removed and replaced by `AssetRepresentation`,
but this would be an even more disruptive change (breaking API
compatibility too).

Also fixes #105535.
Julian Eisel requested review from Bastien Montagne 2023-03-14 19:06:12 +01:00
Julian Eisel added this to the Pipeline, Assets & IO project 2023-03-14 19:06:20 +01:00
Julian Eisel added the
Interest
Asset Browser
label 2023-03-14 19:06:26 +01:00
Julian Eisel added this to the 3.5 milestone 2023-03-14 19:06:30 +01:00
Simon Thommes reviewed 2023-03-14 19:30:43 +01:00
Simon Thommes left a comment
Member

Fixes the crash that I'm having 👍

Fixes the crash that I'm having 👍
Julian Eisel added 1 commit 2023-03-15 11:27:38 +01:00
Hans Goudey changed title from Fix 104305: Crash in node editor with large asset libraries to Fix #104305: Crash in node editor with large asset libraries 2023-03-15 16:20:01 +01:00
Bastien Montagne approved these changes 2023-03-16 15:00:50 +01:00
Bastien Montagne left a comment
Owner

LGTM besides minor points noted below. Don't think we can come we anything better for 3.5.

LGTM besides minor points noted below. Don't think we can come we anything better for 3.5.
@ -0,0 +16,4 @@
#endif
struct ID *ED_asset_get_local_id_from_asset_or_append_and_reuse(
const struct AssetRepresentation *asset_c_ptr, ID_Type idtype, struct Main *bmain);

Would revert order of parameters here, would match better with typical cases in Blender code.

Would revert order of parameters here, would match better with typical cases in Blender code.
@ -59,3 +63,3 @@
}
BLO_library_path_explode(asset_path.c_str(), r_full_lib_path, nullptr, nullptr);
BLI_strncpy(r_full_lib_path, library_path.c_str(), FILE_MAX_LIBEXTRA);

Should just be FILE_MAX ?

Should just be `FILE_MAX` ?

@blender-bot build

@blender-bot build
Julian Eisel added 3 commits 2023-03-16 15:39:37 +01:00
Author
Member

Committed with a958ae36e8.

Committed with a958ae36e8.
Julian Eisel closed this pull request 2023-03-16 16:21:01 +01:00
Julian Eisel deleted branch temp-fix-volatile-asset-handle 2023-03-16 16:21:13 +01:00
Bastien Montagne removed this from the Pipeline, Assets & IO project 2023-07-03 13:01:34 +02:00

Pull request closed

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#105773
No description provided.