Page MenuHome

Python : "get/set" method on a keyed property crashes Blender
Closed, ResolvedPublic


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: rB81b68f7279cd
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



Event Timeline

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.

Campbell Barton (campbellbarton) lowered the priority of this task from Needs Triage by Developer to Confirmed, Low.Wed, Oct 9, 3:47 AM

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 !

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.
Sergey Sharybin (sergey) closed this task as Resolved.Fri, Oct 11, 12:18 PM

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

Thanks for the report, closing.