Crash on Rendering with Mesh Creation/Removal in frame_change_post handler. #73530
Labels
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
8 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#73530
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Linux, Debian
Broken:
dc3f073d1c
current master branchI get non-deterministic/random segfaults on rendering (cycles). I would guess approximately on every 5th frame. Also sometimes. on the first rendering after launching blender. I am not able to fully render a single shot in my current project, so it's an absolute show-stopper for myself at least.
I can reproduce this in various form in a rather complex setup involving a 5k locs inhouse addon. Depending on the the scene update, I get rather different stacktraces, but I guess it's one and the same problem (related to depsgraph).
To reproduce:
I am rather confused about when I should and should not call view_layer.update() after adding/removing mesh objects in the scene. However I get crashes also without updating the view_layer.
I get the following stacktrace for the segfault:
Added subscriber: @aurelw
blender/blender-addons#74216 was marked as duplicate of this issue
Added subscriber: @EAW
Maybe this will help?
https://github.com/JacquesLucke/animation_nodes/pull/1294
081819d738
Added subscriber: @lichtwerk
#71908 might also be related here?
Added subscriber: @brecht
Changed status from 'Needs Triage' to: 'Needs User Info'
This needs at least the relevant sections of code from the add-on.
It matters which exact handler is being used, how dependency graph and evaluated data, if it's modifying original or evalauted data, etc.
@brecht I will put some more time into synthesizing a minimal working example. I was just not able reproduce the segfaults with my first attempt.
I expect that at least one of the crashes related to the deps_graph is cause by just deleting and creating a mesh object in a frame_change_post handler.
The other issues already pointed out seem related, also the fixes/workarounds done in the animation nodes addon (which i don't fully understand yet).
Added subscriber: @intrigus-3
I was able to come up with a minimum example. My more complex code, including modifiers etc. resulted in segfaults with different stacktraces, but I guess it's the same issue triggering it.
Steps to reproduce:
"name": "Crash Min Ex",
"author": "Aurel Wildfellner",
"blender": (2, 81, 0),
"location": "3D View > Toolbox",
"description": "to reproduce a render crash",
"warning": "",
"wiki_url": "",
"support": 'TESTING',
"category": "Mesh"}
import importlib
import bpy
tri_vertices = []
tri_indices = []
tri_vertices.append([1,1,1])
tri_vertices.append([-1,1,1])
tri_vertices.append([1,-1,1])
tri_vertices.append([-1,-1,1])
tri_vertices.append([1,1,-1])
tri_vertices.append([-1,1,-1])
tri_vertices.append([1,-1,-1])
tri_vertices.append([-1,-1,-1])
tri_indices.append([0, 1, 2])
tri_indices.append([1, 3, 2])
tri_indices.append([4, 5, 7])
tri_indices.append([5, 8, 6])
tri_indices.append([1, 0, 5])
tri_indices.append([5, 4, 0])
return (tri_vertices, tri_indices)
scn = context.scene
objects_to_be_removed = []
for obj in scn.objects:
if "support_mesh_foo" in obj.name:
objects_to_be_removed.append(obj.name)
for objname in objects_to_be_removed:
bpy.data.meshes.remove(scn.objects[objname].data,
do_unlink=True)
context.view_layer.update()
print("Build Geometry")
scn = context.scene
if (hasattr(bpy.context, "active_object")):
obj = bpy.context.active_object
else:
obj = None
old_active_obj_name = ""
if hasattr(bpy.context, "active_object"):
if bpy.context.active_object:
old_active_obj_name = bpy.context.active_object.name
removeSupportMeshes(context)
support_mesh_name = "support_mesh_foo"
smesh = bpy.data.meshes.new(support_mesh_name)
sobj = bpy.data.objects.new(support_mesh_name, smesh)
tri_vertices, tri_indices = generateCubeMeshData()
smesh.from_pydata(tri_vertices, [], tri_indices)
scn.collection.objects.link(sobj)
context.view_layer.update()
if old_active_obj_name in scn.objects:
print("setting active object....")
context.view_layer.objects.active =
scn.objects[old_active_obj_name]
scn.objects[old_active_obj_name].select_set(True)
bpy.ops.object.mode_set(mode = 'OBJECT')
context.view_layer.update()
"""Operator triggering crash"""
bl_idname = "mesh.add_cube_crash"
bl_label = "adding cube object"
def execute(self, context):
buildGeometry(context)
pass
print("FRAME CHANGE")
bpy.ops.mesh.add_cube_crash()
MyOperator,
for op in operator_cls:
print("registering operator: ", op.name)
bpy.utils.register_class(op)
bpy.app.handlers.frame_change_post.append(postFrameChangeHandler)
bpy.app.handlers.frame_change_pre.append(preFrameChangeHandler)
for op in operator_cls:
bpy.utils.unregister_class(op)
Does it happen also without calling operators from the handler? It wouldn't surprise me if that causes problems, frame change and depsgraph handlers normally should only use direct API functions. Calling operators with associated undo pushes and other scene updates may well break something.
@brecht the operators from handlers was something I expected myself, but I get also segfaults without any operator involved.
However, I also get the following Python RuntimeError now as well:
The stripped down addon:
Crash on Rendering with Linked Scenesto Crash on Rendering with Mesh Creation/Removal in frame_change_post handler.So after playing around with this a little bit more, I get all sorts of strange behavior.
First of all, that python RuntimeError also is triggered non-determinstically. I am actually not even able to reproduce it right now. Am I not required to update the view layer when adding/removing objects so the view layer is up to date for rendering?
I still get segfaults with this minimal setup, no matter if I view_layer.update() or not. I struggle to find clear, good Information on how to do this correctly, but even with wrong API usage, I guess non-determinstiv error reporting and random crashes are not desired.
I update the issue description accordingly.
Added subscriber: @dr.sybren
Try locking the interface (Render → Lock Interface). If this prevents the crash, it's a known threading issue.
Ok, @dr.sybren I wasn't aware of that. That fixes the issue for me, both in the minimal provided example and in my rendering setup (at least after testing some example shots).
Should this still be considered as a bug then? From my perspective the next person running into such an issue is just a matter of time. Documenting this somehow along the Python API and handlers seems also a good idea.
Changed status from 'Needs User Info' to: 'Archived'
I have added a note about this in the
bpy.app.handlers
API documentation.Added subscribers: @JustinJensen, @iss
@dr.sybren I tried your workaround (Render -> Lock Interface) and it prevented the crash,
but the materials failed to load before the render started, so my mesh rendered as bright pink. Any ideas for this?Update: Sorry, turns out it was a poorly-formed .mtl file. This workaround seems to work fine for me.(@aurelw Did you think your prophecy would come true so quickly? I filed a bug for this just yesterday.)