Page MenuHome

Curve with bevel radius appears black after using Redo Panel (undo issue).
Confirmed, NormalPublicBUG


System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.40

Blender Version
Broken: version: 2.91.2, branch: master, commit date: 2021-01-19 16:15, hash: rB5be9ef417703
(also broken in 2.83, 2.90 and unreleased 2.92)
Worked: 2.82 (pre-undo improvements I believe)

Short description of error
Curve with bevel radius turns black if modifying the property through an operator's redo panel (posibly related to Undo algorithm).

Exact steps for others to reproduce the error

  1. Run the attached script from Blender's Text Editor.
  2. Make sure Undo Legacy is OFF.
  3. From the search menu run the "black curve test" operator TWICE (this will create two curves).
  4. Expand the redo panel(F9) and tweak the bevel radius.

Result: one of the curves turns black in the viewport.

Known Fixes:

  • Enabling Undo Legacy in the Preferences fixes and prevents the issue from happening.
  • Adding bpy.ops.ed.undo_push() in the script's Invoke method.
  • Toggling IN and OUT of Edit Mode.
  • Using bpy.ops to create the bezier curve instead of the manual approach seen in the attatched script.
  • Run the operator once, then click on the viewport to select the curve before running the operator the second time. Not fully tested but having some extra step in between operator runs seems to prevent this bug.

Event Timeline

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Mon, Feb 22, 4:25 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

In my case the curve turns flat gray:

The python code is simple and I haven't found anything that explains that behavior.
I'm not sure if the problem is really in the Undo system, but I'm confirming and tagging the Core project for now.

Think this is an update flag issue... But am still trying to figure out what exactly is going on here, this is fairly weird. Could also be a missing bit in depsgraph update?

Basically, the first curve object (the one turning black) gets ID_RECALC_GEOMETRY | ID_RECALC_SHADING | ID_RECALC_COPY_ON_WRITE recalc flags in DEG eval just after the undo, and shading is not updated. If we add ID_RECALC_TRANSFORM to it, shading does get updated and there is no more black object.

Not sure what exactly is the issue here, to me it makes little sense that you'd have to use TRANSFORM update flag to get shading updated? Would like to get @Jeroen Bakker (jbakker) and @Clément Foucault (fclem) input here, and maybe also @Sergey Sharybin (sergey) or @Sybren A. Stüvel (sybren) for the depsgraph side of things, before diving deeper in the problem.

Note that BKE_object_add_only_object (which is called from RNA object creation) does not set any recalc flag, while higher-level functions like BKE_object_add_for_data (which gets called from Editor code, including operators, when creating a new object) does flag new object with ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION...

From what I can tell, rna_Main_objects_new is not doing any recalc tagging at all actually? Looks suspicious...

Can confirm that adding a DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); to rna_Main_objects_new also fixes the issue, think all those RNA new ID functions should do some recalc tagging in fact?

Bastien Montagne (mont29) moved this task from Backlog to Bugs on the Core board.Tue, Feb 23, 2:30 PM

New objects in depsgraph are supposed to be fully evaluated. As in, in theory, you don't need to tag individual flags after adding new object to depsgraph, depsgraph will decide it for you.

One possible thing thought, is that depsgraph doesn't really handle shading itself: shading is done by the draw manager.

So as a quick fix for annoying issue doing tags is acceptable (although, a bit weird and maybe need ID_RECALC_SHADING in this case?). But it feels that the issue might be a bit deeper in the way how the draw manager is listening to changes and reacts to them.

But it depends on whether it is draw manager is not doing something, or whether there is no data ready for the draw manager. This is not very clear from the explanations here.