Applying Vertex Weight Mix modifier invalidates existing references to Vertex Groups #98751

Closed
opened 2022-06-10 02:43:02 +02:00 by Mysteryem · 8 comments

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 471.11

Blender Version
Broken: 3.0.0, 3.2.0, 3.3.0 Alpha (branch: master, commit date: 2022-06-07 18:08, hash: 173a15bcda)
Worked: 2.93.9

Short description of error
After applying a Vertex Weight Mix modifier, any existing references to Vertex Groups on the object the modifier was applied to become invalid, appearing to no longer reference the correct data in memory.

Exact steps for others to reproduce the error

  • Add vertex groups to the default cube (the more vertex groups there are, the more likely for there to be issues, 10 or more recommended for ease of reproduction)
  • Add a Vertex Weight Mix modifier to the cube
  • Set Vertex Group A and B in the modifier to any two vertex groups on the cube (they can be the same)
  • Select the cube so that is is the active object
  • In a Python Console window, run all_vg = bpy.context.object.vertex_groups[:]
  • Apply the Vertex Weight Mix modifier
  • In the same Python Console as before, run [v.name for v in all_vg]
  • It is likely that a UnicodeDecodeError will occur, some names will end up as the name of a different vertex group or something else entirely, some names will be empty or rarely, that Blender will crash
    Performing other actions in Blender before running [v.name for v in all_vg], such as changing the Properties space from Modifier Properties to Material Properties is likely to cause issues even when there are only very few vertex groups on the cube.
    An alternative to running [v.name for v in all_vg] in the Python Console, that may make the issue clearer, would be to instead run the following code as it will catch the UnicodeDecodeErrors:
for vg in all_vg:

try:
names.append(vg.name)
except UnicodeDecodeError:
names.append('error')


print(names)```
Provided that you enable the System Console for viewing the output and select the default cube as the active object first, the following script can be run from Blender's Text Editor to go through each of the steps (more vertex groups are added because it is much more likely for issues to not occur)

import bpy

cube = bpy.context.object
for _ in range(100):
cube.vertex_groups.new()

mod = cube.modifiers.new('Vertex Weight Mix', 'VERTEX_WEIGHT_MIX')
mod.vertex_group_a = cube.vertex_groups[0].name
mod.vertex_group_b = cube.vertex_groups[1].name

all_vg = cube.vertex_groups[:]

bpy.ops.object.modifier_apply(modifier=mod.name)

names = []
for vg in all_vg:
try:
names.append(vg.name)
except UnicodeDecodeError:
names.append('error')

print(names)

The following lines are to make it easier to repeatedly run the script, they are not required

print()
bpy.context.object.vertex_groups.clear()```

**System Information** Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 471.11 **Blender Version** Broken: 3.0.0, 3.2.0, 3.3.0 Alpha (branch: master, commit date: 2022-06-07 18:08, hash: `173a15bcda`) Worked: 2.93.9 **Short description of error** After applying a Vertex Weight Mix modifier, any existing references to Vertex Groups on the object the modifier was applied to become invalid, appearing to no longer reference the correct data in memory. **Exact steps for others to reproduce the error** - Add vertex groups to the default cube (the more vertex groups there are, the more likely for there to be issues, 10 or more recommended for ease of reproduction) - Add a Vertex Weight Mix modifier to the cube - Set Vertex Group A and B in the modifier to any two vertex groups on the cube (they can be the same) - Select the cube so that is is the active object - In a Python Console window, run `all_vg = bpy.context.object.vertex_groups[:]` - Apply the Vertex Weight Mix modifier - In the same Python Console as before, run `[v.name for v in all_vg]` - It is likely that a UnicodeDecodeError will occur, some names will end up as the name of a different vertex group or something else entirely, some names will be empty or rarely, that Blender will crash Performing other actions in Blender before running `[v.name for v in all_vg]`, such as changing the Properties space from Modifier Properties to Material Properties is likely to cause issues even when there are only very few vertex groups on the cube. An alternative to running `[v.name for v in all_vg]` in the Python Console, that may make the issue clearer, would be to instead run the following code as it will catch the UnicodeDecodeErrors: ```names = [] for vg in all_vg: ``` try: names.append(vg.name) except UnicodeDecodeError: names.append('error') ``` print(names)``` Provided that you enable the System Console for viewing the output and select the default cube as the active object first, the following script can be run from Blender's Text Editor to go through each of the steps (more vertex groups are added because it is much more likely for issues to not occur) ``` import bpy cube = bpy.context.object for _ in range(100): cube.vertex_groups.new() mod = cube.modifiers.new('Vertex Weight Mix', 'VERTEX_WEIGHT_MIX') mod.vertex_group_a = cube.vertex_groups[0].name mod.vertex_group_b = cube.vertex_groups[1].name all_vg = cube.vertex_groups[:] bpy.ops.object.modifier_apply(modifier=mod.name) names = [] for vg in all_vg: try: names.append(vg.name) except UnicodeDecodeError: names.append('error') print(names) # The following lines are to make it easier to repeatedly run the script, they are not required print() bpy.context.object.vertex_groups.clear()```
Author

Added subscriber: @Mysteryem-2

Added subscriber: @Mysteryem-2
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I can't reproduce on any of the listed versions for some reason, both in release and debug builds. Can you try this code instead:

import bpy

cube = bpy.context.object
for _ in range(100):
    cube.vertex_groups.new()

mod = cube.modifiers.new('Vertex Weight Mix', 'VERTEX_WEIGHT_MIX')
mod.vertex_group_a = cube.vertex_groups[0].name
mod.vertex_group_b = cube.vertex_groups[1].name

vertex_groups_copy = cube.vertex_groups[:]

bpy.ops.object.modifier_apply(modifier=mod.name)

for a, b in zip(reversed(vertex_groups_copy), cube.vertex_groups):
    print(a.name, a.as_pointer(), b.name, b.as_pointer())

print("=" * 40)

bpy.context.object.vertex_groups.clear()

Do any of the pointers change?

I can't reproduce on any of the listed versions for some reason, both in release and debug builds. Can you try this code instead: ``` import bpy cube = bpy.context.object for _ in range(100): cube.vertex_groups.new() mod = cube.modifiers.new('Vertex Weight Mix', 'VERTEX_WEIGHT_MIX') mod.vertex_group_a = cube.vertex_groups[0].name mod.vertex_group_b = cube.vertex_groups[1].name vertex_groups_copy = cube.vertex_groups[:] bpy.ops.object.modifier_apply(modifier=mod.name) for a, b in zip(reversed(vertex_groups_copy), cube.vertex_groups): print(a.name, a.as_pointer(), b.name, b.as_pointer()) print("=" * 40) bpy.context.object.vertex_groups.clear() ``` Do any of the pointers change?
Author

In #98751#1372106, @OmarEmaraDev wrote:
I can't reproduce on any of the listed versions for some reason, both in release and debug builds. Can you try this code instead:

[...]
Do any of the pointers change?

(I'm not sure the call to reversed() was supposed to be in your script, I removed it so that the vertex groups would line up).
Yes, on 3.0.0+, all the pointers change. On 2.93.9, the pointers remain the same image.png

> In #98751#1372106, @OmarEmaraDev wrote: > I can't reproduce on any of the listed versions for some reason, both in release and debug builds. Can you try this code instead: > > [...] > Do any of the pointers change? (I'm not sure the call to reversed() was supposed to be in your script, I removed it so that the vertex groups would line up). Yes, on 3.0.0+, all the pointers change. On 2.93.9, the pointers remain the same ![image.png](https://archive.blender.org/developer/F13142953/image.png)
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

The pointers are the same for me in all versions, pre and post 3.0. Since I am on Linux, I will let someone on Windows to triage this and see if it can be confirmed there.

The pointers are the same for me in all versions, pre and post 3.0. Since I am on Linux, I will let someone on Windows to triage this and see if it can be confirmed there.
Member

Closed as duplicate of #93896

Closed as duplicate of #93896
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
2 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#98751
No description provided.