glTF-Blender-IO: Image compositor crash / temporary mesh invalidation

This is a strange crash, and I had some trouble creating a minimal reproduce case for it.

To reproduce it, I needed to:

  • Merge two textures in such a way that they call @scurest’s (awesome) image compositor.
  • Turn on “Smooth Shading” and “Auto Normals” for the mesh, such that it will need normal splitting.
  • Turn on “Apply Modifiers” such that the normals will get split.

Here’s a Blender 2.81a project that will reproduce the problem, but only on newer (2.82) versions of this glTF addon.

crashy_cube.zip

Unfortunately, this crash now happens in the stable release of 2.82. It’s new there, it didn’t happen in the stable release of Blender 2.81a.

But, the problem can be reproduced in 2.81a, if one manually applies a newer version of this addon to it. That means the problem is localized to the addon, not a change in Blender itself. From there I was able to run git bisect to get an exact ID for which commit introduces the problem.

Git bisect says: 4b460489cdba12bb01954a2748cd7209e6549959 is the first bad commit.

The crash writes this to the console:

Traceback (most recent call last):
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\__init__.py", line 487, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 40, in save
    json, buffer = __export(export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 53, in __export
    __gather_gltf(exporter, export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 62, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 37, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 56, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(blender_object, blender_scene, export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 46, in gather_node
    node = __gather_node(blender_object, blender_scene, export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 64, in __gather_node
    mesh=__gather_mesh(blender_object, export_settings),
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 337, in __gather_mesh
    export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_mesh.py", line 43, in gather_mesh
    weights=__gather_weights(blender_mesh, vertex_groups, modifiers, export_settings)
  File "D:\emackey\Git_Large\glTF-Blender-IO\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_mesh.py", line 138, in __gather_weights
    if not export_settings[MORPH] or not blender_mesh.shape_keys:
ReferenceError: StructRNA of type Mesh has been removed

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks a lot @scurest , it was my plan to get this minimal script to reproduce the bug, but you did it first! Thanks 😃

Script to reproduce this without needing the whole addon (maybe useful for asking upstream).

Open @emackey’s crashy_cube.blend, put this in the text editor and run it. It will crash.
If at least one of the if Trues is changed to if False, the crash goes away.

import bpy

ob = bpy.data.objects['Cube']

edge_split = ob.modifiers.new('Temporary_Auto_Smooth', 'EDGE_SPLIT')
ob.data.use_auto_smooth = False

depsgraph = bpy.context.evaluated_depsgraph_get()
mesh_owner = ob.evaluated_get(depsgraph)
mesh = mesh_owner.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)

if True:
    ob.data.use_auto_smooth = True 
    ob.modifiers.remove(edge_split)

if True:
    scn = bpy.data.scenes.new('temp scene')
    scn.use_nodes = True
    scn.node_tree.nodes.remove(scn.node_tree.nodes['Render Layers'])
    bpy.ops.render.render(scene=scn.name, write_still=True)

print(mesh.name)