Editor Assert on Compile/Hot Reload with Custom WorldSettings and HierarchicalInstancedStaticMeshComponent Classes

After setting up a custom WorldSettings class and creating a custom class that inherits UHierarchicalInstancedStaticMeshComponent, the editor will assert every time you make C++ changes and recompile. If you try to open the project again without recompiling, the editor will assert on launch.

This is a very frustrating bug to deal with, as it slows down my work immensely. Every time I make a code change I have to close the editor, recompile, and reopen it.

To reproduce:

  1. Create a new project using the first person C++ template
  2. Add a new C++ class to the project deriving from FoliageInstancedStaticMeshComponent called MyFoliageComponent
  3. Add a new C++ class to the project deriving from WorldSettings called MyWorldSettings
  4. Change the project’s default WorldSettings class to MyWorldSettings (Edit->Project Settings->World Settings Class)
  5. Close and re-open the project
  6. Change one of the project’s C++ files - add a space or something to MyWorldSettings.cpp
  7. Recompile (from the editor or from visual studio)
  8. The editor will assert during hot reload

I debugged this a little -
It seems that during hot reload, the code starts attempting to replace live instances of MyWorldSettings. It comes across a default/CDO object for the custom foliage class, and crashes trying to Serialize it. It crashes because ClusterTreePtr in the Serialize function for UHierarchicalInstancedStaticMeshComponent is null.

The Serialize function appears to lazily build/create the tree if the archive is loading or saving. In this case, however, the archive is neither loading nor saving, but counting references, and so the tree pointer remains null.

Call stack & assertion (also attached in log file link text):

Assertion failed: IsValid() [File:F:\UnrealEngine_Source_4.15\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 826] 

KERNELBASE.dll!0x0000000058953C58
UE4Editor-Core.dll!FOutputDeviceWindowsError::Serialize() [f:\unrealengine_source_4.15\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:120]
UE4Editor-Core.dll!FOutputDevice::Logf__VA() [f:\unrealengine_source_4.15\engine\source\runtime\core\private\misc\outputdevice.cpp:70]
UE4Editor-Core.dll!FDebug::AssertFailed() [f:\unrealengine_source_4.15\engine\source\runtime\core\private\misc\assertionmacros.cpp:349]
UE4Editor-Engine.dll!UHierarchicalInstancedStaticMeshComponent::Serialize() [f:\unrealengine_source_4.15\engine\source\runtime\engine\private\hierarchicalinstancedstaticmesh.cpp:1796]
UE4Editor-CoreUObject.dll!FFindReferencersArchive::ResetPotentialReferencer() [f:\unrealengine_source_4.15\engine\source\runtime\coreuobject\private\serialization\findreferencersarchive.cpp:90]
UE4Editor-UnrealEd.dll!TFindObjectReferencers<UObject>::TFindObjectReferencers<UObject>() [f:\unrealengine_source_4.15\engine\source\runtime\coreuobject\public\serialization\findobjectreferencers.h:49]
.....

Hey extralongpants,

I’ve reproduced the issue, and I noticed we had a ticket in for this crash, but it was missing a repro case. As a result, I’ve updated the ticket and you can track its status using the link below:

Thanks for your report.

Good to hear - thanks!