RuntimeError when baking multiple dynamic paint surfaces in a script #117186

Open
opened 2024-01-16 22:58:09 +01:00 by Ryan Guy · 8 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 4090/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.99

Blender Version
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2024-01-16 15:56, hash: da6b45f9b831
Worked:

Short description of error
I am trying to run a script to bake multiple dynamic paint surfaces as an image sequence but am receiving an error, crash, or incomplete caches upon running the script.

In this setup I have two objects with a dynamic paint canvas added. Each canvas contains two DynamicPaintSurfaces and each is set to output an image sequence to a different cache path. This is the script being used to bake the dynamic paint surfaces:

import bpy

objects = [bpy.data.objects["CanvasObject1"], bpy.data.objects["CanvasObject2"]]
for obj in objects:
    bpy.ops.object.select_all(action='DESELECT')
    bpy.context.view_layer.objects.active = obj
    
    dpaint_modifier = obj.modifiers[0]
    canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces
    for idx in range(len(canvas_surfaces)):
        canvas_surfaces.active_index = idx
        
        print("Begin baking surface: ", bpy.context.view_layer.objects.active.name, canvas_surfaces[canvas_surfaces.active_index].name)
        bpy.ops.dpaint.bake()
        print("Finished baking surface")

When running the script, there seems to be different random outcomes:

  1. A RuntimeError is displayed:
Begin baking surface:  CanvasObject1 Surface_1_1
Finished baking surface
Begin baking surface:  CanvasObject1 Surface_1_2
Finished baking surface
Traceback (most recent call last):
  File "C:\Users\ryanl\Downloads\dpaint_bake_error.blend\Text", line 5, in <module>
  File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 103, in __call__
    _BPyOpsSubModOp._view_layer_update(context)
  File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 68, in _view_layer_update
    view_layer.update()
RuntimeError: Error: Dependency graph update requested during evaluation

Error: Python: Traceback (most recent call last):
  File "C:\Users\ryanl\Downloads\dpaint_bake_error.blend\Text", line 5, in <module>
  File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 103, in __call__
    _BPyOpsSubModOp._view_layer_update(context)
  File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 68, in _view_layer_update
    view_layer.update()
RuntimeError: Error: Dependency graph update requested during evaluation
  1. Blender crashes with an EXCEPTION_ACCESS_VIOLATION. Crash log: dpaint_bake_error.crash.txt
  2. Sometimes the script runs to completion, but not all four unique cache path directories have been generated/baked. Sometimes the script will appear to complete, but Blender hangs and becomes unresponsive.

Exact steps for others to reproduce the error

Attached is a Blend file containing the setup and script: dpaint_bake_error.blend

  1. Open Blend file
  2. Run the script, multiple times if needed

Result: RuntimeError or other outcomes mentioned above.

Let me know if anything else is needed, or if I am misusing the Python API within the script.

**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 4090/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.99 **Blender Version** Broken: version: 4.1.0 Alpha, branch: main, commit date: 2024-01-16 15:56, hash: `da6b45f9b831` Worked: **Short description of error** I am trying to run a script to bake multiple dynamic paint surfaces as an image sequence but am receiving an error, crash, or incomplete caches upon running the script. In this setup I have two objects with a dynamic paint canvas added. Each canvas contains two DynamicPaintSurfaces and each is set to output an image sequence to a different cache path. This is the script being used to bake the dynamic paint surfaces: ```Py import bpy objects = [bpy.data.objects["CanvasObject1"], bpy.data.objects["CanvasObject2"]] for obj in objects: bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = obj dpaint_modifier = obj.modifiers[0] canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces for idx in range(len(canvas_surfaces)): canvas_surfaces.active_index = idx print("Begin baking surface: ", bpy.context.view_layer.objects.active.name, canvas_surfaces[canvas_surfaces.active_index].name) bpy.ops.dpaint.bake() print("Finished baking surface") ``` When running the script, there seems to be different random outcomes: 1. A RuntimeError is displayed: ``` Begin baking surface: CanvasObject1 Surface_1_1 Finished baking surface Begin baking surface: CanvasObject1 Surface_1_2 Finished baking surface Traceback (most recent call last): File "C:\Users\ryanl\Downloads\dpaint_bake_error.blend\Text", line 5, in <module> File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 103, in __call__ _BPyOpsSubModOp._view_layer_update(context) File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 68, in _view_layer_update view_layer.update() RuntimeError: Error: Dependency graph update requested during evaluation Error: Python: Traceback (most recent call last): File "C:\Users\ryanl\Downloads\dpaint_bake_error.blend\Text", line 5, in <module> File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 103, in __call__ _BPyOpsSubModOp._view_layer_update(context) File "C:\Program Files\blender\4.1.0-alpha+main.da6b45f9b831-windows.amd64-release\4.1\scripts\modules\bpy\ops.py", line 68, in _view_layer_update view_layer.update() RuntimeError: Error: Dependency graph update requested during evaluation ``` 2. Blender crashes with an EXCEPTION_ACCESS_VIOLATION. Crash log: [dpaint_bake_error.crash.txt](/attachments/c93b3b47-6614-43c3-a6c9-4651b9f94747) 3. Sometimes the script runs to completion, but not all four unique cache path directories have been generated/baked. Sometimes the script will appear to complete, but Blender hangs and becomes unresponsive. **Exact steps for others to reproduce the error** Attached is a Blend file containing the setup and script: [dpaint_bake_error.blend](/attachments/25148b5c-c7a6-4550-9067-72878a2fde7f) 1. Open Blend file 2. Run the script, multiple times if needed Result: RuntimeError or other outcomes mentioned above. Let me know if anything else is needed, or if I am misusing the Python API within the script.
Ryan Guy added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-01-16 22:58:10 +01:00
Member

Thanks for the report. Can confirm when baking more than one paint-surface. Looks like changing active_index caused this. Because error is triggered prior to second bake function.
Maybe expected behavior since this is terminated when update was sent to viewlayer but depsgraph evaluation wasn't completed

Thanks for the report. Can confirm when baking more than one paint-surface. Looks like changing `active_index` caused this. Because error is triggered prior to second bake function. Maybe expected behavior since this is terminated when update was sent to viewlayer but depsgraph evaluation wasn't completed
Member

Does it help updating the viewlayer after setting its object active (I cant repro the issues anymore after doing that)?

So using this script

import bpy

objects = [bpy.data.objects["CanvasObject1"], bpy.data.objects["CanvasObject2"]]
for obj in objects:
    bpy.ops.object.select_all(action='DESELECT')
    bpy.context.view_layer.objects.active = obj
    bpy.context.view_layer.update()
    
    dpaint_modifier = obj.modifiers[0]
    canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces
    for idx in range(len(canvas_surfaces)):
        canvas_surfaces.active_index = idx
        
        print("Begin baking surface: ", bpy.context.view_layer.objects.active.name, canvas_surfaces[canvas_surfaces.active_index].name)
        bpy.ops.dpaint.bake()
        print("Finished baking surface")
Does it help updating the viewlayer after setting its object active (I cant repro the issues anymore after doing that)? So using this script ```python import bpy objects = [bpy.data.objects["CanvasObject1"], bpy.data.objects["CanvasObject2"]] for obj in objects: bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = obj bpy.context.view_layer.update() dpaint_modifier = obj.modifiers[0] canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces for idx in range(len(canvas_surfaces)): canvas_surfaces.active_index = idx print("Begin baking surface: ", bpy.context.view_layer.objects.active.name, canvas_surfaces[canvas_surfaces.active_index].name) bpy.ops.dpaint.bake() print("Finished baking surface") ```
Philipp Oeser added
Status
Needs Information from User
and removed
Status
Needs Info from Developers
labels 2024-01-17 09:46:34 +01:00
Member

That still triggers the error

That still triggers the error
Author

Thanks for the updates. I am also still triggering the error with the view_layer.update() script.


I was trying to find a workaround to this issue by launching a new Blender instance between bakes and baking each surface individually through a script. The scripts complete without an error, but there seems to be a problem where setting canvas_surfaces.active_index does not take effect for the bake.

For example, if the active_index is currently set to 0 and script sets the value to 1 and runs the bake, this is the result:

  • A cache is generated for the cache path set in DynamicPaintSurfaces of index 0 (//cache_dynamicpaint0)
  • A cache is not generated for the cache path set in DynamicPaintSurfaces of index 1 (//cache_dynamicpaint1)

This is the script I am using and adding view_layer.update() does not seem to affect the result:

# To reproduce:
#    1. Select DynamicPaintSurface: Surface0
#    2. Run Script to select and bake Surface1
#
#    Result: A cache is generated for the cache path of     Surface0 (//cache_dynamicpaint0)
#            A cache is not generated for the cache path of Surface1 (//cache_dynamicpaint1)

import bpy

obj = bpy.data.objects["CanvasObject1"]
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.objects.active = obj

dpaint_modifier = obj.modifiers[0]
canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces
canvas_surfaces.active_index = 1

print("Begin baking surface: ", 
      bpy.context.view_layer.objects.active.name, 
      canvas_surfaces.active.name, 
      canvas_surfaces.active.image_output_path)
bpy.ops.dpaint.bake()
print("Finished baking surface")

Script output:

Begin baking surface:  CanvasObject1 Surface1 //cache_dynamicpaint1
Finished baking surface

Blend file including the setup and script: dpaint_bake_incorrect_cache_path.blend

If this should be opened as a separate issue, let me know.

Thanks for the updates. I am also still triggering the error with the ```view_layer.update()``` script. --- I was trying to find a workaround to this issue by launching a new Blender instance between bakes and baking each surface individually through a script. The scripts complete without an error, but there seems to be a problem where setting ```canvas_surfaces.active_index``` does not take effect for the bake. For example, if the active_index is currently set to 0 and script sets the value to 1 and runs the bake, this is the result: - A cache is generated for the cache path set in DynamicPaintSurfaces of index 0 (//cache_dynamicpaint0) - A cache is **not** generated for the cache path set in DynamicPaintSurfaces of index 1 (//cache_dynamicpaint1) This is the script I am using and adding ```view_layer.update()``` does not seem to affect the result: ``` # To reproduce: # 1. Select DynamicPaintSurface: Surface0 # 2. Run Script to select and bake Surface1 # # Result: A cache is generated for the cache path of Surface0 (//cache_dynamicpaint0) # A cache is not generated for the cache path of Surface1 (//cache_dynamicpaint1) import bpy obj = bpy.data.objects["CanvasObject1"] bpy.ops.object.select_all(action='DESELECT') bpy.context.view_layer.objects.active = obj dpaint_modifier = obj.modifiers[0] canvas_surfaces = dpaint_modifier.canvas_settings.canvas_surfaces canvas_surfaces.active_index = 1 print("Begin baking surface: ", bpy.context.view_layer.objects.active.name, canvas_surfaces.active.name, canvas_surfaces.active.image_output_path) bpy.ops.dpaint.bake() print("Finished baking surface") ``` Script output: ``` Begin baking surface: CanvasObject1 Surface1 //cache_dynamicpaint1 Finished baking surface ``` Blend file including the setup and script: [dpaint_bake_incorrect_cache_path.blend](/attachments/32a04508-cad9-4ab7-9a3e-d978cbc2d92a) If this should be opened as a separate issue, let me know.
Member

I see, it still writes to the path of previous active surface.

I see, it still writes to the path of previous active surface.
Member

@lichtwerk , I think this can be marked as confirmed

@lichtwerk , I think this can be marked as `confirmed`
Member

@PratikPB2123 @rlguy : I still cannot repro for some reason but feel free to confirm if you can

@PratikPB2123 @rlguy : I still cannot repro for some reason but feel free to confirm if you can
Author

Just confirming that I am able to reproduce the issue on:

Windows-10-10.0.22621-SP0 64 Bits
4.1.0 Beta, branch: blender-v4.1-release, commit date: 2024-02-13 23:35, hash: c6e229d3e470
4.2.0 Alpha, branch: main, commit date: 2024-02-14 11:02, hash: 2cec7e3aa59b

Just confirming that I am able to reproduce the issue on: Windows-10-10.0.22621-SP0 64 Bits 4.1.0 Beta, branch: blender-v4.1-release, commit date: 2024-02-13 23:35, hash: `c6e229d3e470` 4.2.0 Alpha, branch: main, commit date: 2024-02-14 11:02, hash: `2cec7e3aa59b`
Pratik Borhade added
Status
Confirmed
and removed
Status
Needs Information from User
labels 2024-02-15 04:54:33 +01: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
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#117186
No description provided.