Python : "get/set" method on a keyed property crashes Blender #70660

Closed
opened 2019-10-09 02:57:40 +02:00 by Stanislas Paillereau · 7 comments

System Information
Operating system: Linux-4.19.75-07002-gcaf981fa9892-x86_64-with-debian-9.9 64 Bits
Graphics card: virgl Red Hat 4.3 (Core Profile) Mesa 19.2.0-devel

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-06-08 13:24, hash: blender/blender@81b68f7279
Worked: (optional)

Short description of error
Using the "get/set" methods on a property (FloatProperty) in python to update a mesh data crashes blender when the property is keyed.
All is good when changing the value of the property in the ui but scrolling in the timeline crashes blender.

Exact steps for others to reproduce the error

  • Open the PythonPropertyBug.blend file. Run the script to create the custom the property that declare a set/get methods.
  • Change the value in the UI : everything work fine.
  • Scroll the timeline (property is already keyed) : blender crashes

PythonPropertyBug.blend

**System Information** Operating system: Linux-4.19.75-07002-gcaf981fa9892-x86_64-with-debian-9.9 64 Bits Graphics card: virgl Red Hat 4.3 (Core Profile) Mesa 19.2.0-devel **Blender Version** Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-06-08 13:24, hash: `blender/blender@81b68f7279` Worked: (optional) **Short description of error** Using the "get/set" methods on a property (FloatProperty) in python to update a mesh data crashes blender when the property is keyed. All is good when changing the value of the property in the ui but scrolling in the timeline crashes blender. **Exact steps for others to reproduce the error** - Open the PythonPropertyBug.blend file. Run the script to create the custom the property that declare a set/get methods. - Change the value in the UI : everything work fine. - Scroll the timeline (property is already keyed) : blender crashes [PythonPropertyBug.blend](https://archive.blender.org/developer/F7797969/PythonPropertyBug.blend)

Added subscriber: @StanislasPaillereau

Added subscriber: @StanislasPaillereau

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Sergey Sharybin was assigned by Campbell Barton 2019-10-09 03:46:46 +02:00

Fairly sure calling view_layer.update() within a set function isn't supported.

Instead you should call ID.update_tag(...).

Even so, this should raise an error instead of crashing.

Fairly sure calling view_layer.update() within a set function isn't supported. Instead you should call `ID.update_tag(...)`. Even so, this should raise an error instead of crashing.

ID.update_tag(...) doesn't refresh on the viewport while scrolling in the timeline. Going to edit mode refreshes the mesh in the viewport.

Did also some test with update_tag:
Using the refresh option set to {'OBJECT', 'DATA', 'TIME'} make scrolling the property in the UI to freak out. Seems the 'TIME' entry is the faulty one.

Hope that helps

Thx !
Stan

`ID.update_tag(...) ` doesn't refresh on the viewport while scrolling in the timeline. Going to edit mode refreshes the mesh in the viewport. Did also some test with update_tag: Using the refresh option set to {'OBJECT', 'DATA', 'TIME'} make scrolling the property in the UI to freak out. Seems the 'TIME' entry is the faulty one. Hope that helps Thx ! Stan

Short story: neither of update or tagging should happen from set() functions.

Long story.
The set() functions are used by the animation system to store new value for the property. So what happens in this file is: the set() function is asking dependency graph to be evaluated while it is being evaluated. This is not supported and can not be. Is just something to stay away from.

Tagging will effectively do nothing, because the way how dependency graph does not use tags during evaluation (they are only used to initialize evaluation).

I've submitted D6035 which makes it so update requested during evaluation will raise an exception in Python.

There are two possible approaches which first Blender's design:

  1. Use python expression/function as a driver.
  2. Use handlers.
Short story: neither of update or tagging should happen from `set()` functions. Long story. The `set()` functions are used by the animation system to store new value for the property. So what happens in this file is: the `set()` function is asking dependency graph to be evaluated while it is being evaluated. This is not supported and can not be. Is just something to stay away from. Tagging will effectively do nothing, because the way how dependency graph does not use tags during evaluation (they are only used to initialize evaluation). I've submitted [D6035](https://archive.blender.org/developer/D6035) which makes it so update requested during evaluation will raise an exception in Python. There are two possible approaches which first Blender's design: 1. Use python expression/function as a driver. 2. Use handlers.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

The crashes are now fixed. The rest is to be addressed in the .blend file itself.

Thanks for the report, closing.

The crashes are now fixed. The rest is to be addressed in the .blend file itself. Thanks for the report, closing.
Sign in to join this conversation.
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-addons#70660
No description provided.