Page MenuHome

Exporting procedural mesh animation with Alembic results in a crash
Closed, DuplicatePublic

Description

System Information
Operating system: Windows 10 Home
Graphics card: GTX 1070 8GB

Blender Version
Broken: 2.80, 4fe0fafb8755, 2019-07-24
Worked: 2.79, 5bd8ac9, 2017-09-11

Short description of error

Exporting a procedural mesh to Alembic that is updated in the frame_change_pre handler results in a crash. This is an issue that is being encountered in the FLIP Fluids addon. I have created a small script that reproduces this issue.

The script and steps to reproduce this issue are similar to this report: T65816

import bpy

def frame_change_pre(scene):
    # A triangle that shifts in the z direction
    zshift = scene.frame_current * 0.1
    vertices = [(-1, -1, zshift), (1, -1, zshift), (0, 1, zshift)]
    triangles = [(0, 1, 2)]
    
    new_mesh_data = bpy.data.meshes.new("mesh_data" + str(scene.frame_current))
    new_mesh_data.from_pydata(vertices, [], triangles)
    
    mesh_cache = bpy.data.objects.get("mesh_cache")
    old_mesh_data = mesh_cache.data
    mesh_cache.data = new_mesh_data
    bpy.data.meshes.remove(old_mesh_data)
    
bpy.app.handlers.frame_change_pre.append(frame_change_pre)

This is the error output after the crash:

Read blend: C:\Users\ryanl\Downloads\procedural_alembic_export.blend
find_node component: Could not find ID MEmesh_data272
add_relation(Object Geometry Base Data) - Could not find op_from (ComponentKey(MEmesh_data272, GEOMETRY))
add_relation(Object Geometry Base Data) - Failed, but op_to (ComponentKey(OBmesh_cache, GEOMETRY)) was ok
find_node_operation: Failed for (PARAMETERS_ENTRY, '')
find_node_operation: Failed for (PARAMETERS_EVAL, '')
add_relation(Entry -> Eval) - Could not find op_from (OperationKey(type: PARAMETERS, component name: '', operation code: PARAMETERS_ENTRY))
add_relation(Entry -> Eval) - Could not find op_to (OperationKey(type: PARAMETERS, component name: '', operation code: PARAMETERS_EVAL))
find_node_operation: Failed for (PARAMETERS_EVAL, '')
find_node_operation: Failed for (PARAMETERS_EXIT, '')
add_relation(Entry -> Exit) - Could not find op_from (OperationKey(type: PARAMETERS, component name: '', operation code: PARAMETERS_EVAL))
add_relation(Entry -> Exit) - Could not find op_to (OperationKey(type: PARAMETERS, component name: '', operation code: PARAMETERS_EXIT))
find_node_operation: Failed for (GEOMETRY_EVAL, '')
find_node_operation: Failed for (GEOMETRY_EVAL_DONE, '')
add_relation(ObData Geom Eval Done) - Could not find op_from (OperationKey(type: GEOMETRY, component name: '', operation code: GEOMETRY_EVAL))
add_relation(ObData Geom Eval Done) - Could not find op_to (OperationKey(type: GEOMETRY, component name: '', operation code: GEOMETRY_EVAL_DONE))
find_node_operation: Failed for (GEOMETRY_SELECT_UPDATE, '')
add_relation(Data Selection -> Object Selection) - Could not find op_from (OperationKey(type: BATCH_CACHE, component name: '', operation code: GEOMETRY_SELECT_UPDATE))
add_relation(Data Selection -> Object Selection) - Failed, but op_to (OperationKey(type: BATCH_CACHE, component name: '', operation code: GEOMETRY_SELECT_UPDATE)) was ok
find_node_operation: Failed for (COPY_ON_WRITE, '')
add_relation(Eval Order) - Could not find op_from (OperationKey(type: COPY_ON_WRITE, component name: '', operation code: COPY_ON_WRITE))
add_relation(Eval Order) - Failed, but op_to (OperationKey(type: COPY_ON_WRITE, component name: '', operation code: COPY_ON_WRITE)) was ok
Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF70639C627
Error   : EXCEPTION_ACCESS_VIOLATION
Module  : C:\Users\ryanl\Downloads\blender-2.80.0-git.4fe0fafb8755-windows64\blender.exe

Sometimes the error output is this:

Read blend: C:\Users\ryanl\Downloads\procedural_alembic_export.blend
Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF70650CD40
Module  : C:\Users\ryanl\Downloads\blender-2.80.0-git.4fe0fafb8755-windows64\blender.exe

Exact steps for others to reproduce the error

I have attached a .blend file that will reproduce the issue.

  1. Open .blend file
  2. Run the script
  3. File > Export > Alembic

Blender does not crash 100% of the time. It seems that the chance of a crash occurring increases as the frame range increases. I have the end frame set to 2000, which results in a crash most of the time on my system.

Event Timeline

Hey @Sybren A. Stüvel (sybren) what do you think about this?

It seems that @Ryan G (rlguy) tried to use any of these handlers:

frame_change_pre
frame_change_post
render_pre
render_post

But it seems the crash is there with any of those.
I tried with your patch for the other bug but the crash is still present in this case.

Note: render_pre and render_post handlers will not cause a crash in this issue since these are only called during render. I had tested the frame change and render handlers in issue T60094 which all resulted in a crash.

Sybren A. Stüvel (sybren) lowered the priority of this task from 90 to 50.

There are two things happening in the reported code:

  • The mesh object is replaced. This means the exporter is going to see it as a different mesh. Instead of having one mesh animated over time, you'll have a separate static mesh for every frame.
  • The changes in the data aren't seen by the export depsgraph, see T60094.

I've added a function (rB6d2f9b1dfa98) to Blender that allows you to avoid replacing the mesh datablock. You can now write the code like this:

def frame_change_pre(scene):
    # A triangle that shifts in the z direction
    zshift = scene.frame_current * 0.1
    vertices = [(-1, -1, zshift), (1, -1, zshift), (0, 1, zshift)]
    triangles = [(0, 1, 2)]

    object = bpy.data.objects["The Object"]
    object.data.clear_geometry()
    object.data.from_pydata(vertices, [], triangles)

Note the new object.data.clear_geometry() function. This will erase all geometry from the mesh, and allow a subsequent from_pydata() call to fill it up again. It also just tags the mesh for geometry updates in the depsgraph; creating a new mesh datablock and deleting the old one will cause a complete rebuild of the relations in the depsgraph, which is more expensive.

The remaining part of this task is now the same as T60094, so I'll merge this task as a duplicate.