Skip to content

Blender crashes when exporting or rendering animation generated from exported.assets.py #669

@TomMontagnon

Description

@TomMontagnon

Description

When I run the following code (inspired by and simplified from
src/demos/postprocess/demo_POST_povray2.cpp):

#include "chrono/assets/ChVisualShapeBox.h"
#include "chrono/assets/ChVisualShapeSphere.h"
#include "chrono/physics/ChParticleCloud.h"
#include "chrono/physics/ChSystemNSC.h"

#include "chrono_postprocess/ChBlender.h"

#include "chrono_thirdparty/filesystem/path.h"

using namespace chrono;
using namespace chrono::postprocess;

int main(int argc, char* argv[]) {
    std::cout << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << std::endl;

    // Create output directory
    std::string out_dir = GetChronoOutputPath() + "BLENDER_TEST";
    if (!filesystem::create_directory(filesystem::path(out_dir))) {
        std::cout << "Error creating directory " << out_dir << std::endl;
        return 1;
    }

    // Create a Chrono system and set the associated collision system
    ChSystemNSC sys;
    ChCollisionModel::SetDefaultSuggestedEnvelope(1e-3);
    ChCollisionModel::SetDefaultSuggestedMargin(1e-3);
    sys.SetCollisionSystemType(ChCollisionSystem::Type::BULLET);

    // Create the floor body
    auto floor = chrono_types::make_shared<ChBody>();
    floor->SetFixed(true);

    auto floor_ct_mat = chrono_types::make_shared<ChContactMaterialNSC>();
    auto floor_ct_shape = chrono_types::make_shared<ChCollisionShapeBox>(floor_ct_mat, 0.2, 0.04, 0.2);
    floor->AddCollisionShape(floor_ct_shape);
    floor->EnableCollision(true);

    auto floor_vis_shape = chrono_types::make_shared<ChVisualShapeBox>(0.2, 0.04, 0.2);
    floor_vis_shape->SetColor(ChColor(0.5f, 0.5f, 0.5f));
    floor->AddVisualShape(floor_vis_shape);

    sys.Add(floor);
    
    int ix =0, iz=0;
    auto body = chrono_types::make_shared<ChBody>();
    body->SetPos(ChVector3d(0.05 + ix * 0.021, 0.04, 0 + iz * 0.021));
    body->SetMass(0.02);
    body->SetInertiaXX(ChVector3d((2.0 / 5.0) * (0.01 * 0.01) * 0.02));

    auto body_ct_shape = chrono_types::make_shared<ChCollisionShapeBox>(floor_ct_mat, 0.02, 0.02, 0.02);
    body->AddCollisionShape(body_ct_shape);
    body->EnableCollision(true);

    auto body_vis_shape = chrono_types::make_shared<ChVisualShapeBox>(0.02, 0.02, 0.02);
    body->AddVisualShape(body_vis_shape);

    sys.Add(body);

    // Create an exporter to POVray
    ChBlender pov_exporter = ChBlender(&sys);
    // pov_exporter.SetTemplateFile(GetChronoDataFile("POVRay_chrono_template.pov"));
    pov_exporter.SetBasePath(out_dir);

    pov_exporter.SetCamera(ChVector3d(0.2, 0.3, 0.5), ChVector3d(0, 0, 0), 35);
    pov_exporter.SetLight(ChVector3d(-2, 2, -1), ChColor(1.0f, 1.0f, 1.0f), true);
    pov_exporter.SetPictureSize(1200, 900);

    pov_exporter.AddAll();

    pov_exporter.ExportScript();

    sys.SetSolverType(ChSolver::Type::PSOR);
    sys.GetSolver()->AsIterative()->SetMaxIterations(50);

    while (sys.GetChTime() < 0.7) {
        sys.DoStepDynamics(0.005);
        std::cout << "time = " << sys.GetChTime() << std::endl;
        pov_exporter.ExportData();
    }

    return 0;
}

it generates an exported.assets.py file, which can be successfully imported into Blender.

The animation plays correctly in the Blender viewport preview.


❌ Problem

Blender crashes in the following situations:

  1. When exporting the animation to USD (with animation)
    Blender crashes systematically with :
zsh: segmentation fault (core dumped)  blender-4.4.3

→ A crash report is attached here. blender.crash.txt

  1. When rendering the animation, especially:

    • Video render using FFMPEG
    • The crash occurs during the animation render

This is unexpected, as:

  • The same Blender + FFMPEG setup works perfectly on other projects
  • Those other projects include scenes that are significantly more complex

During rendering, Blender outputs the following error before crashing:

zsh: segmentation fault (core dumped)  blender-4.4.3

→ A crash report is attached here. blender.crash.txt

Hypothesis:

Both crashes are likely related and originate from an invalid or improperly constructed scene generated by the export pipeline.
Although the scene can be evaluated correctly for viewport playback, it may contain malformed data (e.g. invalid transforms, corrupted animation data, or unsupported object states) that causes Blender to crash during USD export and during offline rendering (FFMPEG), where stricter evaluation and full scene traversal are required.

Environment

  • Chrono version: 9.0 (commit 341f39c )
  • Blender version: 4.4.3
  • OS: Ubuntu 24.04.1

Compilation options:

BUILD_DEMOS=On
BUILD_SHARED_LIBS=On
CH_ENABLE_MODULE_IRRLICHT=On
CH_ENABLE_MODULE_POSTPROCESS=On
CH_ENABLE_MODULE_PYTHON=On
CH_ENABLE_OPENMP=On
CH_USE_BULLET_OPENMP=On
CH_USE_EIGEN_OPENMP=On
CH_USE_SIMD=On

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions