And here are analysis from Claude Code
[5.8] Foliage AddInstances() crashes when the MeshPartition plugin is enabled
Version: 5.8.1 | Platform: Win64 Editor | Repro: 100%
Repro
- New blank project, enable the MeshPartition plugin (Experimental), restart.
- Run in the Python console:
import unreal
w = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_editor_world()
ft = unreal.EditorAssetLibrary.load_asset('/Game/FT_Test') # any UFoliageType
unreal.InstancedFoliageActor.add_instances(w, ft, [unreal.Transform()])
Editor crashes with EXCEPTION_ACCESS_VIOLATION reading address 0x10.
The Blueprint Add Instances node crashes identically. Disabling MeshPartition
fixes it.
Root cause
FFoliageInstanceBaseCache::AddInstanceBaseId() calls the new-in-5.8
IFoliageEditModuleBase hook before null-checking the component
(Runtime/Foliage/Private/FoliageInstanceBase.cpp:126):
if (IFoliageEditModuleBase* FoliageModule = IFoliageEditModuleBase::Get(); ensure(FoliageModule))
{
bIgnoreComponentClass = FoliageModule->ShouldIgnoreComponentForBaseID(InComponent); // nullptr
}
#endif
if (InComponent && !InComponent->IsCreatedByConstructionScript() && !bIgnoreComponentClass) // too late
and the implementation dereferences it unguarded
(Editor/FoliageEdit/Private/FoliageEditModule.cpp:262):
for (TSoftObjectPtr<UClass> ClassToCheckPtr : ComponentBaseIDClassesToIgnore)
if (UClass* ClassToCheck = ClassToCheckPtr.Get())
if (InComponent->IsA(ClassToCheck)) // <-- AV, InComponent is null
AddInstanceImpl (InstancedFoliage.cpp:2281) passes null because
FFoliageInstances created by the AddInstances UFUNCTION have no
BaseComponent, and the API doesn’t expose one. Interactive brush painting
survives only because it has a real hit component.
The crash needs ComponentBaseIDClassesToIgnore to be non-empty, and the only
thing in the engine that populates it is
FMeshPartitionEditorModule::RegisterFoliageBaseIDClassIgnoreList()
(MeshPartitionEditor/Private/MeshPartitionEditorModule.cpp:143), which
registers three classes at startup. Hence: MeshPartition on = every scripted
foliage add crashes.
Regression
New in 5.8. 5.7 had no hook and null-checked first:
if (InComponent && !InComponent->IsCreatedByConstructionScript()).
Fix
One line in ShouldIgnoreComponentForBaseID:
if (!InComponent) { return false; }
(or guard the call site in AddInstanceBaseId — ideally both).