Crash compiling Blueprint child of native class with a HISM component

Just found a bug with HISM (hierarchical instanced static mesh) component and was finally able to setup reproduction steps. I’ve sent a bug report but I’m posting here in case anyone has a similar issue and might know a solution already.

The problem is that compiling Blueprint child of native class containing a private HISM component with transforms updated in OnConstruct crashes the editor.

#Reproduction steps

.

  • Create a new C++ project.
  • Add an Actor C++ class to it.
  • Create HISMComponent as private UPROPERTY so that its instances are kept on Actor duplication with Alt+Drag. Add AllowPrivateAccess=“true” to the UPROPERTY meta tag.
  • Override OnConstructor and add at least one instance to the HISM and update its transform.
  • After compiling, in the editor create a Blueprint child of the created native class. Open it and click compile.

#Detailed description
​​​​​​​A native actor with a private HISM component, even if adding instances and updating their transforms in OnConstruction, compile successfully, can be spawned in the level by dragging it from the content browser and can duplicated with Alt+Drag, keeping its instances. But if a child Blueprint of such actor is created, even though nothing is changed, we can’t even compile it without crashing the editor.

After several tests, it seems one or more of the instance data arrays in the HISM class (like InstanceReorderTable) is not correctly synchronized with the other arrays. Sometimes the crash is in a failed check inside AddInstance, where it checks if the next instance index is equal to InstanceReorderTable.Num(), which indicates that it has registered instances not accounted for by the rest of the code.

Same code worked on UE 4.19. Except that it didn’t need the AllowPrivateAccess meta tag in the component uproperty.

Here are project files with the code: http://files.rvillani.com/unreal/HISMBug.zip

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

Hi, Jeff! I know. But it doesn’t help others with the same problem. So I filed the report and also posted it here.

And, for now, I found a workaround: use only C++.
It seems the problem (and also a visual one in my other post) is related only to Blueprints. If the class using HISMCs is purely native, no crashes occur. But even the class’s children have to be native. Any Blueprint intervention and it crashes.

BTW, I wouldn’t be able to share this workaround with the community by using only the bug report form.