[4.20] Hierarchical Instanced Static Mesh crash in many ways if used in C++


Issue UE-62282.


Hey all,

my HISM component crash all the time and for many reason, this happen if i add an instance or when i set the static mesh, also happen if i clean instances, it’s hard to understand which of this trigger the crash but they all have the same crash report:


Assertion failed: (void)((&ElementData[InstanceIndex])

    1. <= (void*)(InstanceOriginDataPtr + CurrentSize) [File:D:\Build++UE4\Sync\Engine\Source\Runtime\Engine\Public\StaticMeshResources.h] [Line: 1231]

UE4Editor_Core!FDebug::AssertFailed() [d:\build++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:425]

UE4Editor_Engine!FStaticMeshInstanceBuffer::UpdateFromCommandBuffer_RenderThread() [d:\build++ue4\sync\engine\source\runtime\engine\private\instancedstaticmesh.cpp:189]

UE4Editor_Engine!TGraphTask::ExecuteTask() [d:\build++ue4\sync\engine\source\runtime\core\public\async\taskgraphinterfaces.h:829]

UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [d:\build++ue4\sync\engine\source\runtime\core\private\async\taskgraph.cpp:665]

UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\build++ue4\sync\engine\source\runtime\core\private\async\taskgraph.cpp:574]

UE4Editor_RenderCore!RenderingThreadMain() [d:\build++ue4\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:333]

UE4Editor_RenderCore!FRenderingThread::Run() [d:\build++ue4\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:467]

UE4Editor_Core!FRunnableThreadWin::Run() [d:\build++ue4\sync\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:76]


looks like something when wrong with rendering.

This it’s a blocker for me and i have to come back on 4.19 (thanks god i have a backup of the project).

EDIT:

Step to reproduce:

  1. Open a new C++ project

  2. Create an Actor class

  3. Add an Hierarchical Instanced Static Mesh Component

    ATestActor::ATestActor()
    {
    // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
    PrimaryActorTick.bCanEverTick = true;

     HISMComp = CreateDefaultSubobject<UHierarchicalInstancedStaticMeshComponent>(TEXT("HISMComp"));
     HISMComp->SetupAttachment(GetRootComponent());
    

    }

  4. Do some operations on it (like add a bunch of instances OnConstruction or BeginPlay)

    void ATestActor::BeginPlay()
    {
    Super::BeginPlay();

     HISMComp->ClearInstances();
     for (int i = 0; i < 10; i++)
     {
     	HISMComp->AddInstance(GetActorTransform() + FTransform(FRotator(0.f, 0.f 0.f), FVector(i * 50.f, 0.f, 0.f)));
     }
    

    }

  5. Launch the editor and drop your actor in the level

  6. If you are lucky and it’s not crashed yet try to set the component static mesh.

as i said sometime happen when you clean or add instances (80% of time if used in OnConstruction) or when you set the static mesh (100% both OnConstruction and BeginPlay in my test behaviour).

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

I’m sorry, i forgot that there is the new form for bug reports, thanks for the heads up.

Have the same problem. Constantly crashes when I try to set mesh property or duplicate actor with mesh already set into HISMComponent.

In Log

[2018.07.29-18.31.07:110][  0]LogWindows: Error: Assertion failed: (void*)((&ElementData[InstanceIndex]) + 1) <= (void*)(InstanceOriginDataPtr + CurrentSize) [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Public\StaticMeshResources.h] [Line: 1231] 

Also for Blueprints version of actor with HISMComponent I have another log

[2018.07.29-18.31.06:219][  0]LogLinker: Warning: Unable to load PhysicsSerializer with outer HierarchicalInstancedStaticMeshComponent /Game/Environment/Procedural/BP_Proc_Base.BP_Proc_Base_C:HierarchicalInstancedStaticMesh_GEN_VARIABLE because its class does not exist

I submitted the issue with the new bug report form, they have replicated the problem Unreal Engine Issues and Bug Tracker (UE-62282)

I had this warning too and fix it by renaming my InstancedStaticMeshComponent.

I was able to fix this by normalizing the transform rotation in the two places that it uses ToMatrixWithScale, we will test internally then PR if nothing is wrong.

Please remove the bug report from this post. It has nothing to do with it. Look at the crash log; Assertion failed: IsRotationNormalized() ; The crash is clearly shown to be different in the thread Assertion failed: (void)((∈Data[InstanceIndex]) + 1) <= (void*)(InstanceOriginDataPtr + CurrentSize) . I’ve fixed the one in the bug report but the one in the thread is much more severe and undecipherable but anyone who didn’t write it.
I made a forum thread here: Engine bug related to HISM / Foliage Spawners causing map/tile corruption - Engine Source & GitHub - Unreal Engine Forums

No, this bug report was sent to me from Epic after my bug submission,

Hello Yuri,

I have reproduced this issue and
logged a report for it here
Unreal Engine Issues and Bug Tracker (UE-62282).
You can track the report’s status as
the issue is reviewed by our
development staff. Please let us know
if you have any other questions about
this issue, or would like to discuss
how you may be able to fix this
yourself if this is urgent for your
project.

also the crash log change from test to test here, there is more than one problem with HISM.

Regardless, the bug report is irrelevant to this thread. That ones an easy fix. Normalize the transform rotation.
The actual bug still is unreported and significantly more obscure.
Maybe reply and notify epic?

For the record, your reproduction steps never result in the crash in this thread once I fix the one in the PR. So there’s still no bug report for this one and no reproduction steps for it either.

@ZioYuri78 do you use Speed Tree in the project this crash occurs in? The answerhub crash not the bug report crash.

Questioning if it’s even a bug. It only occurs when passing a non-normalized rotation, which rather makes sense when expecting a direction. Otherwise what would you expect to happen. Feel like it’s a huge distraction from the actual bug.

Simp)e implementation was fine in 4.19, and started crashing in 4.20, so yes, it is definitely a bug.

I didn’t checked it after last hotfix, but I will.

Nope, i literally did the steps i write in op, create the component, add a bunch of instances, drop in the level, crash.

Ok, i becoming confused now, what i have to do? Remove the link to the bug report and send another one?

No one on my team can reproduce the bug using the steps shown. Only the one in the bug report.

I was able to load the tile by updating the HISM code to master (4.22) and removing the checks, however the result is as the check suggests; the instanced meshes are corrupted. Know when your GPU overheats and you get strange vertex stretching? (See images in this thread) - it looks like the foliage is doing a similar thing. So basically the bug is vertex corruption in instanced static meshes, only with foliage (based on the few reports we have). The actual check failing is not a bug.

Unfortunately this means we basically hope Epic inadvertently fix the issue at some point. They might already have done so.

More info in my thread here, especially later posts

In 4.20.3 my case is still reproduced.

[2018.10.07-09.03.56:311][311]LogWindows: Error: Fatal error: [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp] [Line: 826] 
[2018.10.07-09.03.56:311][311]LogWindows: Error: Rendering thread exception:
[2018.10.07-09.03.56:311][311]LogWindows: Error: Assertion failed: (void*)((&ElementData[InstanceIndex]) + 1) <= (void*)(InstanceOriginDataPtr + CurrentSize) [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Public\StaticMeshResources.h] [Line: 1231]

I have another crash in implementation with blueprints. It also related to mesh component, so every time I try to set mesh, I get this:

[2018.10.11-16.57.26:920][777]LogWindows: Error: Assertion failed: InstancingRandomSeed != 0 [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\HierarchicalInstancedStaticMesh.cpp] [Line: 2785] 

Guys, this is really critical stuff! 4.20 already had 3 hotfixes, and all of them didn’t has fixes for HISM Components troubles!

HISM functionality is very important part of engine to ignore this bugs!