Recursive Purge Orphans datablocks on file save #87490

Open
opened 2021-04-14 12:46:39 +02:00 by Demeter Dzadik · 10 comments
Member

Fully deleting datablocks from a blend file doesn't happen as easily as most users might expect, since "delete" is often used in the UI when "un-link" is what is actually meant. This can cause a lot of confusion and uncertainty during production. Proper deletion of datablocks requires that they are first un-linked, then they can be purged via File->Clean Up->Recursive Unused Datablocks. This works beautifully, and I would like to propose adding an option to have this operation executed after existing deletion operators. For example, after deleting a collection of objects, it would then also delete everything that was used only by those objects, such as their mesh and shape key datablocks, materials, actions, textures, etc.

My previous proposal was to have an option to execute Recursive Purge only on file save, which seemed to make sense to everyone I talked to at the time. (@dr.sybren @mont29 @JulianEisel @SimonThommes )
I still think that solution would be a step forward, but the new proposal above would achieve the same goals in an even more foolproof way.

Use case

Currently, this can very easily happen:

  • Animator duplicates an overridden character. All its objects get a .001 suffix.
  • Animator deletes that copy, saves their file, and later re-opens it. Only one "layer" of unused objects has been cleaned, so there can still be orphan object datablocks lying around unseen.
  • Animator duplicates the character again. Now the number suffix of their objects are all over the place. Some of them have .001 and others have .002.

As they continue working and duplicating characters, the old, unused objects slowly get deleted, and the name suffixes really get all over the place. It's not nice to get your objects names all mixed up like this, as things get really confusing when trying to troubleshoot problems in a production file, since everywhere where one object references another, the mismatching suffixes give the troubleshooter anxiety and uncertainty. The only way to avoid this currently is to tell the entire production team to always run a recursive Purge after deleting anything, which is very error-prone.

Potential issues

  • ~~The current recursive purge purges Text datablocks, which is bad because they don't have the possibility of a "Fake User", so they should be excluded (or better yet, be included in the "fake user" system, and get a fake user by default). ~~ (Fixed by D10983)
  • Actions don't have fake user enabled by default. The long standing issue of Action datablocks "disappearing" on users and making them lose hours of work if they forget to click Fake User would be exacerbated by this change. This could be trivially fixed by giving Actions a fake user on creation, and forcing users to clean up their unused Actions themselves.
Fully deleting datablocks from a blend file doesn't happen as easily as most users might expect, since "delete" is often used in the UI when "un-link" is what is actually meant. This can cause a lot of confusion and uncertainty during production. Proper deletion of datablocks requires that they are first un-linked, then they can be purged via File->Clean Up->Recursive Unused Datablocks. This works beautifully, and I would like to propose adding an option to have this operation executed after existing deletion operators. For example, after deleting a collection of objects, it would then also delete everything that was used only by those objects, such as their mesh and shape key datablocks, materials, actions, textures, etc. My previous proposal was to have an option to execute Recursive Purge only on file save, which seemed to make sense to everyone I talked to at the time. (@dr.sybren @mont29 @JulianEisel @SimonThommes ) I still think that solution would be a step forward, but the new proposal above would achieve the same goals in an even more foolproof way. ### Use case Currently, this can very easily happen: - Animator duplicates an overridden character. All its objects get a .001 suffix. - Animator deletes that copy, saves their file, and later re-opens it. Only one "layer" of unused objects has been cleaned, so there can still be orphan object datablocks lying around unseen. - Animator duplicates the character again. Now the number suffix of their objects are all over the place. Some of them have .001 and others have .002. As they continue working and duplicating characters, the old, unused objects slowly get deleted, and the name suffixes really get all over the place. It's not nice to get your objects names all mixed up like this, as things get really confusing when trying to troubleshoot problems in a production file, since everywhere where one object references another, the mismatching suffixes give the troubleshooter anxiety and uncertainty. The only way to avoid this currently is to tell the entire production team to always run a recursive Purge after deleting anything, which is very error-prone. ### Potential issues - ~~The current recursive purge purges Text datablocks, which is bad because they don't have the possibility of a "Fake User", so they should be excluded (or better yet, be included in the "fake user" system, and get a fake user by default). ~~ (Fixed by [D10983](https://archive.blender.org/developer/D10983)) - Actions don't have fake user enabled by default. The long standing issue of Action datablocks "disappearing" on users and making them lose hours of work if they forget to click Fake User would be exacerbated by this change. This could be trivially fixed by giving Actions a fake user on creation, and forcing users to clean up their unused Actions themselves.
Author
Member
Added subscribers: @SimonThommes, @JulianEisel, @mont29, @dr.sybren, @Mets
Author
Member

Marking as "Good first issue" on Julian's suggestion, if any contributors would like to pick this up, it's probably(hopefully) simple on the implementation side.

Marking as "Good first issue" on Julian's suggestion, if any contributors would like to pick this up, it's probably(hopefully) simple on the implementation side.

Also related to #61209 (Always write unused IDs on save)

Also related to #61209 (Always write unused IDs on save)
Author
Member

Whoops, so much for "Good first issue"! I forgot about that task, thanks for the reminder. Maybe this task is sort of redundant then, since the design proposed in #61209 solves the same issues, and perhaps more elegantly. It's just a shame since that seems like a pretty daunting task that probably won't be tackled for some time, so until then I am left with shoving a "Purge All" button in the animation team's face and hope that they press it often. :/

With that design in mind, I think what I'm asking for here could manifest as a "Purge on Save" user preference, that would bring back the old(current) behaviour except with a recursive purge. (Performance be damned.) Alternatively, it would be interesting to explore more ways to allow datablocks to not have to share a name space. Right now, linked and local datablocks are in separate name spaces, which I think is great. If we could have a similar thing for deleted databloks, I think that could be interesting, and also make sense from user PoV.

@mont29 Do you think it's better to close this task and add my thoughts to the discussion in the other thread, or is it worthwhile to keep this separate?

Whoops, so much for "Good first issue"! I forgot about that task, thanks for the reminder. Maybe this task is sort of redundant then, since the design proposed in #61209 solves the same issues, and perhaps more elegantly. It's just a shame since that seems like a pretty daunting task that probably won't be tackled for some time, so until then I am left with shoving a "Purge All" button in the animation team's face and hope that they press it often. :/ With that design in mind, I think what I'm asking for here could manifest as a "Purge on Save" user preference, that would bring back the old(current) behaviour except with a recursive purge. (Performance be damned.) Alternatively, it would be interesting to explore more ways to allow datablocks to not have to share a name space. Right now, linked and local datablocks are in separate name spaces, which I think is great. If we could have a similar thing for deleted databloks, I think that could be interesting, and also make sense from user PoV. @mont29 Do you think it's better to close this task and add my thoughts to the discussion in the other thread, or is it worthwhile to keep this separate?

@Mets would keep both for now, while related they are not entirely the same. We can re-iterate on designs and such once we actually start working on those.

@Mets would keep both for now, while related they are not entirely the same. We can re-iterate on designs and such once we actually start working on those.

Added subscriber: @ckohl_art

Added subscriber: @ckohl_art
Contributor

Added subscriber: @RedMser

Added subscriber: @RedMser
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

In #87490#1146406, @mont29 wrote:
@Mets would keep both for now, while related they are not entirely the same. We can re-iterate on designs and such once we actually start working on those.

Would assume this can be confirmed as a status then (to get it out of the triaging queue).

> In #87490#1146406, @mont29 wrote: > @Mets would keep both for now, while related they are not entirely the same. We can re-iterate on designs and such once we actually start working on those. Would assume this can be confirmed as a status then (to get it out of the triaging queue).
Philipp Oeser removed the
Interest
Core
label 2023-02-09 14:43:12 +01:00
Sign in to join this conversation.
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
5 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#87490
No description provided.