Description

Calling UHierarchicalInstancedStaticMeshComponent::AddInstance multiple times causes multiple BuildTrees to be created and run asynchronously at the same time.

Tested in 4.21(CL - 4613538)

 

How the steps reproduce above are technically not a recommended process, codewise, but it is still an issue.

A workaround for this issue is to set UHierarchicalInstancedStaticMeshComponent::bAutoRebuildTreeOnInstanceChanges to false before the loop where UHierarchicalInstancedStaticMeshComponent::AddInstance gets called multiple times, set it back to true after the loop, call UHierarchicalInstancedStaticMeshComponent::BuildTreeIfOutdated(true, true), and finally UHierarchicalInstancedStaticMeshComponent::Modify()

Steps to Reproduce
  1. Create a Blank project
  2. Create a derived AActor class called MyBaseActor that has the Abstract specifier in its UCLASS macro
  3. Within the AMyBaseActor class, have a UHierarchicalInstancedStaticMeshComponent created on itself within the constructor
  4. Create a derived AMyBaseActor class called MyActor
  5. Within the AMyActor class, create a function named GenerateTransforms  that first calls UHierarhicalInstancedStaticMeshComponent::ClearInstance, then have it call UHierarchicalInstancedStaticMeshComponent::AddInstance for each mesh within the HISM component  
  6. Override the PostEditChangeProperty function in the AMyActor class to call the GenerateTransforms function
  7. Drag the MyActor class to the scene
  8. Add a cube static mesh added to the HierarchicalInstancedStaticMeshComponent (HISM) of the AMyActor instance in the scene
  9. Create 9 instances of the Cube Static Mesh in the HISM
  10. Copy and Paste the AMyActor instance
Callstack

LoginId:6b5940ce425805aa9506178fb7822a35 EpicAccountId: Assertion failed: (void*)((&ElementData[InstanceIndex]) + 1) <= (void*)(InstanceOriginDataPtr + CurrentSize) [Link Removed] [Line: 1233] UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:417] UE4Editor_Engine!FStaticMeshInstanceBuffer::UpdateFromCommandBuffer_RenderThread() [d:\build\++ue4\sync\engine\source\runtime\engine\private\instancedstaticmesh.cpp:247] UE4Editor_Engine!TGraphTask<TEnqueueUniqueRenderCommandType<`FStaticMeshInstanceBuffer::UpdateFromCommandBuffer_Concurrent'::`2'::InstanceBuffer_UpdateFromPreallocatedDataName,<lambda_8f141d6f12b5e9ba7bbe98accef238b8> > >::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:679] UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\build\++ue4\sync\engine\source\runtime\core\private\async\taskgraph.cpp:575] 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]

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-68582 in the post.

3
Login to Vote

Fixed
ComponentTools - Foliage
Affects Versions4.21.1
Target Fix4.23
Fix Commit6675399
Main Commit6838042
CreatedJan 16, 2019
ResolvedMay 30, 2019
UpdatedJul 29, 2019