Page MenuHome

Exporting procedural mesh animation with Alembic results in a static mesh and can cause crashes
Closed, ResolvedPublic

Description

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

Blender Version
Broken: 2.80, 8ac0fef4dfd1, 2019-06-14
Worked: 2.79, 5bd8ac9, 2017-09-11

Short description of error

I have created a small script that updates an object mesh geometry within a frame_change_pre handler. Now I want to export the animation using the Alembic exporter. I have added a modifier to the object so that it is recognized as an animated mesh during Alembic export (according to this comment).

In Blender 2.79, the exported mesh is animated, but in Blender 2.80 the exported mesh is static.

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)

Exact steps for others to reproduce the error

I have attached a .blend file that will reproduce the issue and that will run in both 2.79 and 2.80.

  1. Open .blend file in Blender 2.80
  2. Run the script
  3. File > Export > Alembic
  4. Import the Alembic cache into the scene

Result: the Alembic cache is not animated

Event Timeline

Sebastian Parborg (zeddb) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

I'm getting an assert on export:

BLI_assert failed: /home/zed/prog/blender/source/blender/blenkernel/intern/object.c:3358, BKE_object_get_pre_modified_mesh(), at 'object->runtime.mesh_orig->id.orig_id == ((Object *)object->id.orig_id)->data'

If I ignore that, I get an other assert when opening the exported file:

blender: /usr/include/boost/smart_ptr/shared_ptr.hpp:734: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = Alembic::Abc::v11::TypedArraySample<Alembic::Abc::v11::V2fTPTraits>; typename boost::detail::sp_member_access<T>::type = Alembic::Abc::v11::TypedArraySample<Alembic::Abc::v11::V2fTPTraits>*]: Assertion `px != 0' failed.

If I ignore that too, I get a segfault on import:

Thread 36 "blender" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffcdffe700 (LWP 18292)]
read_mpolys (config=..., mesh_data=...) at /home/zed/prog/blender/source/blender/alembic/intern/abc_mesh.cc:833
833	  const size_t uvs_size = uvs->size();
(gdb) bt
#0  read_mpolys (config=..., mesh_data=...) at /home/zed/prog/blender/source/blender/alembic/intern/abc_mesh.cc:833
#1  0x0000555556a962e5 in read_mesh_sample (settings=<synthetic pointer>, do_normals=<synthetic pointer>: <optimized out>, config=..., selector=...,
    schema=..., iobject_full_name="/mesh_cache/mesh_cacheShape") at /home/zed/prog/blender/source/blender/alembic/intern/abc_mesh.cc:1030
#2  AbcMeshReader::read_mesh (this=0x7fffce86f400, existing_mesh=0x7fffce80ed08, sample_sel=..., read_flag=<optimized out>, err_str=<optimized out>)
    at /home/zed/prog/blender/source/blender/alembic/intern/abc_mesh.cc:1175
#3  0x0000555556a955c5 in AbcMeshReader::readObjectData (this=0x7fffce86f400, bmain=0x7fffd32fd808, sample_sel=...)
    at /home/zed/prog/blender/source/blender/alembic/intern/abc_mesh.cc:1081
#4  0x0000555556a64631 in import_startjob (user_data=0x7fffd2ddb200, stop=<optimized out>, do_update=<optimized out>, progress=<optimized out>)
    at /home/zed/prog/blender/source/blender/alembic/intern/alembic_capi.cc:713
#5  0x000055555652560f in do_job_thread (job_v=0x7fffd0016dc8) at /home/zed/prog/blender/source/blender/windowmanager/intern/wm_jobs.c:376
#6  0x00007ffff6a09458 in start_thread () from /lib64/libpthread.so.0
#7  0x00007ffff326b71f in clone () from /lib64/libc.so.6

I'm guessing this is related to reported issue here.

@Sebastian Parborg (zeddb) that segfault isn't related, and is fixed in 964e319a39ab.

@Sybren A. Stüvel (sybren) But you can reproduce the issue mentioned here?

I can. A solution is more tricky, though; I'm working on a new way to iterate the depsgraph and properly use evaluated data for exporting to USD, which we can also use to export to Alembic. However, such a major change is probably too major to put into the 2.80 release.

How is this going?

This is preventing from being able to properly export a fluid simulation to alembic, Blender crashes, this is the terminal output, on windows 10 x64, today's master from build bot:

Is there a workaround?
It's a pretty big bug and an important one if we have to work with a fluids project (as we have to do right now)

Cheers.

@Juan Gea (juang3d) What you describe is not the same problem as is discussed here. If you have a crash, please write a separate bug report via the "Report Bug" item in the "Help" menu.

I’ve been directed towards this bug by the Flip Fluids Addon developer, that is why I assumed that this is the same bug.
I’ll report a different bug if you think it’s a different one :)

Thanks!

Ryan G (rlguy) added a comment.EditedJul 22 2019, 11:51 PM

I have recently received a few reports from users of the FLIP Fluids addon that this issue is now resulting in crashes rather than the static exported Alembic caches reported in the original post. I have just had a chance to test this on the most recent Blender 2.80 build (02c5c091dfd6) and have been able to confirm this crash using the .blend file and instructions in the original post.

This is the error that I receive:

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

find_node component: Could not find ID MEmesh_data217
add_relation(Object Geometry Base Data) - Could not find op_from (ComponentKey(MEmesh_data217, GEOMETRY))
add_relation(Object Geometry Base Data) - Failed, but op_to (ComponentKey(OBmesh_cache, GEOMETRY)) was ok
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 : 0x00007FF75D68CD20
Module  : C:\Users\ryanl\Downloads\blender-2.80.0-git.02c5c091dfd6-windows64\blender.exe

Sometimes running the test results in this error message instead:

Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF75D6B86CF
Module  : C:\Users\ryanl\Downloads\blender-2.80.0-git.02c5c091dfd6-windows64\blender.exe

Note: the crashes do not occur 100% of the time. The frequency of crashes seem to increase as the length of animation frames increases. Extending the end frame to 2000 rather than 30 in the default .blend file seems to result in a crash every time on my home system.

Again, please read the original report. It is about Alembic exporting a static mesh. It's not about Blender crashing. If you have a crash, it's a different bug. If it's about fluid simulation, you're probably experiencing T52814 which has a fix in D5191, which will be included in Blender 2.81.

I’ll report it later :)

So I've investigated this a bit more and it's a different bug for sure.

The current bug is still present, I don't experience any crahses using the sample blend file and the script, but there is no animation export in the alembic export, but I saw that the patch is not included in 2.80 (too risky), I'll add the patch to my own build and I'll try to export the Flip Fluid result to see if anything changes regarding the crashes (I assume the triangle export thing will work of course).

On the other hand, @Ryan G (rlguy) will post another bug for the export crash, it only happens with Flip Fluids addon, Mantaflow (version built today) and Elbeem exports are correct.

Cheers.

This issue depends on T60094 being fixed first.

Sybren A. Stüvel (sybren) renamed this task from Exporting procedural mesh animation with Alembic results in a static mesh to Exporting procedural mesh animation with Alembic results in a static mesh and can cause crashes.Sep 18 2019, 5:01 PM