Regression: Attributes shared between meshes after modification #109670

Closed
opened 2023-07-03 22:16:33 +02:00 by Jose Conseco · 8 comments

System Information
Operating system: Linux-6.1.31-2-MANJARO-x86_64-with-glibc2.37 64 Bits, X11 UI
Graphics card: NVIDIA GeForce RTX 3060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 530.41.03

Blender Version
Broken: version: 3.6.0, branch: blender-v3.6-release, commit date: 2023-06-27 08:08, hash: c7fc78b81ecb
Worked: 3.5.1

behavior changed with 7eee378ecc

Short description of error
Lets say we have cube object, with 2d vector attribute (on Points, not sure if domain matters).
When creating cube copy, (with mesh copy - not instance), 2d Vector attribute (named 'test' in blend file ), stays linked to the original attribute.

Exact steps for others to reproduce the error

  1. Run script :
    -it will write 1, to 'test' attribute on cube,
  • then create cube copy (not linked),
  • then write 0 to test attribute on cube_copy
    When we print 'test' attrib value, you will see both attributes (on both object) was set to (0,0), but original attribute on cube should not have been affected (it should print (1,1) and not (0,0) ) .
    Above script works ok on blender 3.5.1 ( print 1 for original cube, 0 - for copy). There is also no issue for Int attributes. I did not test other domains / data types.
**System Information** Operating system: Linux-6.1.31-2-MANJARO-x86_64-with-glibc2.37 64 Bits, X11 UI Graphics card: NVIDIA GeForce RTX 3060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 530.41.03 **Blender Version** Broken: version: 3.6.0, branch: blender-v3.6-release, commit date: 2023-06-27 08:08, hash: `c7fc78b81ecb` Worked: 3.5.1 behavior changed with 7eee378eccc8f87e1330b9cfea2799928be9d657 **Short description of error** Lets say we have cube object, with 2d vector attribute (on Points, not sure if domain matters). When creating cube copy, (with mesh copy - not instance), 2d Vector attribute (named 'test' in blend file ), stays linked to the original attribute. **Exact steps for others to reproduce the error** 1. Run script : -it will write **1**, to 'test' attribute on **cube**, - then create cube copy (not linked), - then write **0** to test attribute on **cube_copy** When we print 'test' attrib value, you will see both attributes (on both object) was set to (0,0), but original attribute on cube should not have been affected (it should print (1,1) and not (0,0) ) . Above script works ok on blender 3.5.1 ( print 1 for original cube, 0 - for copy). There is also no issue for Int attributes. I did not test other domains / data types.
Jose Conseco added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-07-03 22:16:34 +02:00
Iliya Katushenock changed title from [REGRESSION] 2d vector attribute, not unlinked correctly on mesh copy. to Regression: 2d vector attribute, not unlinked correctly on mesh copy 2023-07-03 22:31:43 +02:00
Iliya Katushenock added
Module
Python API
Status
Confirmed
Interest
Modeling
and removed
Status
Needs Triage
labels 2023-07-03 22:36:23 +02:00
Member

Can we please label recent regressions with High priority?

Will check which commit broke this...

Can we please label recent regressions with High priority? Will check which commit broke this...
Philipp Oeser added
Priority
High
and removed
Priority
Normal
labels 2023-07-04 14:41:46 +02:00

@lichtwerk I didn't know if it was a regression...
So it would be better to check if it's a bug first

@lichtwerk I didn't know if it was a regression... So it would be better to check if it's a bug first
Member

First : triaging (this does not include classification as Bug or something else, this ultimately is up to the module to decide).
This seems to be a bug though, copying (non-linked) should not share data like that.

Also: the title says "Regression", and a previous working version is mentioned (3.5.1), this should all be verified if you triage a report.
Please refer to https://wiki.blender.org/wiki/Process/A_Bugs_Life, https://wiki.blender.org/wiki/Process/Bug_Reports

Anyways, in this case the behavior changed with 7eee378ecc

From the commit message:

Now the potentially long arrays referenced by custom
data layers can be shared between different systems but most importantly
between different geometries. This makes e.g. copying a mesh much cheaper
because none of the attributes has to be copied. Only when an attribute
is modified does it have to be copied

In this case, the attribute is clearly modified, so sharing should not happen anymore.

CC @JacquesLucke

First : triaging (this does not include classification as Bug or something else, this ultimately is up to the module to decide). This seems to be a bug though, copying (non-linked) should not share data like that. Also: the title says "Regression", and a previous working version is mentioned (3.5.1), this should all be verified if you triage a report. Please refer to https://wiki.blender.org/wiki/Process/A_Bugs_Life, https://wiki.blender.org/wiki/Process/Bug_Reports Anyways, in this case the behavior changed with 7eee378eccc8f87e1330b9cfea2799928be9d657 From the commit message: >Now the potentially long arrays referenced by custom data layers can be shared between different systems but most importantly between different geometries. This makes e.g. copying a mesh much cheaper because none of the attributes has to be copied. Only when an attribute is modified does it have to be copied In this case, the attribute is clearly modified, so sharing should not happen anymore. CC @JacquesLucke
Philipp Oeser added
Module
Modeling
Interest
Nodes & Physics
and removed
Module
Python API
Interest
Modeling
labels 2023-07-04 15:11:14 +02:00
Member

I don't think this issue is limited to 2D integer attributes. All attribute types are now shared, and rna_Attribute_data_begin doesn't ensure that the attribute data is mutable (un-share it if it has more than 1 user).

However, this exposes a larger issue with the RNA API. Because we have no idea if users of the API intend to modify the attribute data, we will have to always un-share the data, even for something like an exporter that just wants to read the data. This is "correct" but it's very inefficient!

@brecht, did you ever think about this issue regarding attributes and RNA before? Currently I'd propose something like adding a data_read_only RNA method that returns a different type that isn't settable. Or breaking the API and using our internal for_write naming convention in RNA. Maybe it would be possible to provide an array more directly accessible with Python too, so .value or .vector isn't necessary (not sure if that's related though).

I don't think this issue is limited to 2D integer attributes. All attribute types are now shared, and `rna_Attribute_data_begin` doesn't ensure that the attribute data is mutable (un-share it if it has more than 1 user). However, this exposes a larger issue with the RNA API. Because we have no idea if users of the API intend to modify the attribute data, we will have to _always_ un-share the data, even for something like an exporter that just wants to read the data. This is "correct" but it's very inefficient! @brecht, did you ever think about this issue regarding attributes and RNA before? Currently I'd propose something like adding a `data_read_only` RNA method that returns a different type that isn't settable. Or breaking the API and using our internal `for_write` naming convention in RNA. Maybe it would be possible to provide an array more directly accessible with Python too, so `.value` or `.vector` isn't necessary (not sure if that's related though).
Hans Goudey added
Type
Bug
and removed
Type
Report
labels 2023-07-05 17:18:38 +02:00

I didn't really consider it. For Python scripts I guess it's simplest if we can hide this, and automatically make the attribute mutable whenever RNA set is called. But then you need to store indices into the array since the pointer to an element gets invalidated.

I didn't really consider it. For Python scripts I guess it's simplest if we can hide this, and automatically make the attribute mutable whenever RNA set is called. But then you need to store indices into the array since the pointer to an element gets invalidated.
Member

Yes, it would be nice to handle it automatically. The changing pointers makes that tricky though, I haven't thought of a way to make that work yet. We'd need to store the CustomDataLayer pointer in PointerRNA as well as the index, and there isn't space for that. I'll think a bit more.

Yes, it would be nice to handle it automatically. The changing pointers makes that tricky though, I haven't thought of a way to make that work yet. We'd need to store the `CustomDataLayer` pointer in `PointerRNA` as well as the index, and there isn't space for that. I'll think a bit more.

I didn't really consider it. For Python scripts I guess it's simplest if we can hide this, and automatically make the attribute mutable whenever RNA set is called. But then you need to store indices into the array since the pointer to an element gets invalidated.

Which is the same underlying problem we have in #107500 , where the pointer also gets invalidated. If we change attribute RNA to not directly point to the data, but always store a (name based?) reference to the attribute and an index we could catch both these issues at the same time. But that's a quite lowlevel change to RNA and we'd need to be smart about it because doing name based attribute lookups per element would be very inefficient.

> I didn't really consider it. For Python scripts I guess it's simplest if we can hide this, and automatically make the attribute mutable whenever RNA set is called. But then you need to store indices into the array since the pointer to an element gets invalidated. Which is the same underlying problem we have in #107500 , where the pointer also gets invalidated. If we change attribute RNA to not directly point to the data, but always store a (name based?) reference to the attribute and an index we could catch both these issues at the same time. But that's a quite lowlevel change to RNA and we'd need to be smart about it because doing name based attribute lookups per element would be very inefficient.

Yes, it would be nice to handle it automatically. The changing pointers makes that tricky though, I haven't thought of a way to make that work yet. We'd need to store the CustomDataLayer pointer in PointerRNA as well as the index, and there isn't space for that. I'll think a bit more.

Thinking about this: storing CustomDataLayer pointers is dangerous as long as thge layers still get moved around. same #107500 problem.

> Yes, it would be nice to handle it automatically. The changing pointers makes that tricky though, I haven't thought of a way to make that work yet. We'd need to store the `CustomDataLayer` pointer in `PointerRNA` as well as the index, and there isn't space for that. I'll think a bit more. Thinking about this: storing CustomDataLayer pointers is dangerous as long as thge layers still get moved around. same #107500 problem.
Hans Goudey changed title from Regression: 2d vector attribute, not unlinked correctly on mesh copy to Regression: Attributes shared between meshes after modification 2023-07-10 13:58:28 +02:00
Jacques Lucke was assigned by Dalai Felinto 2023-09-12 13:00:27 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-09-12 13:03:14 +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
6 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#109670
No description provided.