Purging orphan data deletes used mesh #107573

Closed
opened 2023-05-03 08:29:10 +02:00 by Ingo Clemens · 5 comments

System Information
Operating system: macOS-13.3.1-arm64-arm-64bit 64 Bits
Graphics card: Metal API Apple M1 Max 1.2

Blender Version
All previous versions of Blender (tested from 3.3 and later)
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-19 22:06, hash: f87e474af004
Broken: 3.3 LTS
Worked: 3.2.0

Caused by 97dd107070

Short description of error
When purging orphan data from the scene (from the Outliner Orphan view) a used mesh gets removed if it has a material applied, which uses a Texture Coordinate node with the Object property set to the object itself.

Exact steps for others to reproduce the error

  • Create a mesh.
  • Assign a new material.
  • Create a standard texture set for any material channel: Texture Coordinate, Mapping, Texture
  • Select the object itself for the Object property of the Texture Coordinate node.
  • Open a Outliner window and switch it to the Orphan view.
  • Press Purge. The info will indicate that one material and one mesh will be deleted.
  • After confirming the object is gone.

A sample scene is attached.

**System Information** Operating system: macOS-13.3.1-arm64-arm-64bit 64 Bits Graphics card: Metal API Apple M1 Max 1.2 **Blender Version** All previous versions of Blender (tested from 3.3 and later) Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-19 22:06, hash: `f87e474af004` Broken: 3.3 LTS Worked: 3.2.0 Caused by 97dd107070 **Short description of error** When purging orphan data from the scene (from the Outliner Orphan view) a used mesh gets removed if it has a material applied, which uses a Texture Coordinate node with the Object property set to the object itself. **Exact steps for others to reproduce the error** - Create a mesh. - Assign a new material. - Create a standard texture set for any material channel: Texture Coordinate, Mapping, Texture - Select the object itself for the Object property of the Texture Coordinate node. - Open a Outliner window and switch it to the Orphan view. - Press Purge. The info will indicate that one material and one mesh will be deleted. - After confirming the object is gone. A sample scene is attached.
Ingo Clemens added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-05-03 08:29:11 +02:00
Member

Can confirm. If not select the object in the node, purging would not affect it. Will check older versions. Worked in 3.1.0, later all broken.

Note in 3.3.2 when purging it shows an additional image data block.

Looks like the user count is indeed increasing when selecting the object, so I'm not sure what caused it.

Can confirm. If not select the object in the node, purging would not affect it. ~~Will check older versions.~~ Worked in 3.1.0, later all broken. Note in 3.3.2 when purging it shows an additional image data block. Looks like the user count is indeed increasing when selecting the object, so I'm not sure what caused it.
YimingWu added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-05-03 09:08:13 +02:00
Member

Will check

Will check
Member

What I could figure out so far:

source/blender/blenkernel/intern/lib_query.c line 717 has a loop dependency detection mechanism that considers the "cube as its own user" as "not a valid user" due to the recursive nature... Basically here the cube is only being used 1 time by the cube's shader, so the if ((id_from->tag & tag) == 0) { has_valid_from_users = true; } is never executed.

Those are by @mont29

/* Preemptively consider this ID as unused. That way if there is a loop of dependency leading
   * back to it, it won't create a fake 'valid user' detection.
   * NOTE: there are some cases (like when fake user is set, or some ID types) which are never
   * 'indirectly unused'. However, these have already been checked and early-returned above, so any
   * ID reaching this point of the function can be tagged. */
  id->tag |= tag;
  for (MainIDRelationsEntryItem *id_from_item = id_relations->from_ids; id_from_item != NULL;
       id_from_item = id_from_item->next)
  {
    if ((id_from_item->usage_flag & ignored_usages) != 0 ||
        (id_from_item->usage_flag & required_usages) == 0)
    {
      continue;
    }

    ID *id_from = id_from_item->id_pointer.from;
    if ((id_from->flag & LIB_EMBEDDED_DATA) != 0) {
      /* Directly 'by-pass' to actual real ID owner. */
      id_from = BKE_id_owner_get(id_from);
      BLI_assert(id_from != NULL);
    }

    lib_query_unused_ids_tag_recurse(
        bmain, tag, do_local_ids, do_linked_ids, id_from, r_num_tagged);
    if ((id_from->tag & tag) == 0) {
      has_valid_from_users = true;  // <------ In the case in this specific report, looks like this line is never executed for the cube.
      break;
    }
  }
  if (has_valid_from_users) {
    /* This ID has 'valid' users, clear the 'tag as unused' preemptively set above. */
    id->tag &= ~tag;
  }
  else {
    /* This ID has no 'valid' users, its 'unused' tag preemptively set above can be kept. */
    if (r_num_tagged != NULL) {
      r_num_tagged[INDEX_ID_NULL]++;
      r_num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++;
    }
  }
What I could figure out so far: `source/blender/blenkernel/intern/lib_query.c` line 717 has a loop dependency detection mechanism that considers the "cube as its own user" as "not a valid user" due to the recursive nature... Basically here the cube is only being used 1 time by the cube's shader, so the `if ((id_from->tag & tag) == 0) { has_valid_from_users = true; }` is never executed. Those are by @mont29 ``` /* Preemptively consider this ID as unused. That way if there is a loop of dependency leading * back to it, it won't create a fake 'valid user' detection. * NOTE: there are some cases (like when fake user is set, or some ID types) which are never * 'indirectly unused'. However, these have already been checked and early-returned above, so any * ID reaching this point of the function can be tagged. */ id->tag |= tag; for (MainIDRelationsEntryItem *id_from_item = id_relations->from_ids; id_from_item != NULL; id_from_item = id_from_item->next) { if ((id_from_item->usage_flag & ignored_usages) != 0 || (id_from_item->usage_flag & required_usages) == 0) { continue; } ID *id_from = id_from_item->id_pointer.from; if ((id_from->flag & LIB_EMBEDDED_DATA) != 0) { /* Directly 'by-pass' to actual real ID owner. */ id_from = BKE_id_owner_get(id_from); BLI_assert(id_from != NULL); } lib_query_unused_ids_tag_recurse( bmain, tag, do_local_ids, do_linked_ids, id_from, r_num_tagged); if ((id_from->tag & tag) == 0) { has_valid_from_users = true; // <------ In the case in this specific report, looks like this line is never executed for the cube. break; } } if (has_valid_from_users) { /* This ID has 'valid' users, clear the 'tag as unused' preemptively set above. */ id->tag &= ~tag; } else { /* This ID has no 'valid' users, its 'unused' tag preemptively set above can be kept. */ if (r_num_tagged != NULL) { r_num_tagged[INDEX_ID_NULL]++; r_num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++; } } ```
Member

Yep, caused by 97dd107070

Yep, caused by 97dd10707097
Philipp Oeser added the
Module
Core
Interest
ID Management
labels 2023-05-03 09:44:26 +02:00

The Cube object should also be used by the collection which owns it? Will check what happens here.

The Cube object should also be used by the collection which owns it? Will check what happens here.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-05-03 16:52:05 +02: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
4 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#107573
No description provided.