Description

If NewObject is used to create an instanced static mesh component at runtime, populating the component with AddInstance causes the editor to crash.

Regression:
Yes - repro steps provided did not crash in 4.17.1 (CL 3586342)

Steps to Reproduce
  1. Open UE4 Editor (any project)
  2. Add code to project based on Actor (MyActor)
  3. Add the following to MyActor.h
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
    	class UInstancedStaticMeshComponent* ISMC;
    
  4. Add the following to the MyActor::BeginPlay() function in MyActor.cpp
    	ISMC = NewObject<UInstancedStaticMeshComponent>(this, TEXT("Something"));
    	ISMC->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
    	ISMC->RegisterComponent();
    
    	FTransform Rando = FTransform::Identity;
    	ISMC->AddInstance(Rando);
    
  5. Compile
  6. In the editor, place an instance of MyActor in the level

Result:
Editor crashes with provided callstack

Expected:
PIE runs and component is created

Callstack
LoginId:7156c35640f86204e61b8383f45dee17
EpicAccountId:c807849e05a0413d99e379f2802cae9c

Fatal error: [File:D:\Build\++UE4+Release-4.17+Compile\Sync\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11VertexDeclaration.cpp] [Line: 49] Unknown RHI vertex element type 0

UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:349]
UE4Editor_D3D11RHI!FD3D11VertexDeclarationKey::FD3D11VertexDeclarationKey() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\windows\d3d11rhi\private\d3d11vertexdeclaration.cpp:53]
UE4Editor_D3D11RHI!FD3D11DynamicRHI::RHICreateVertexDeclaration() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\windows\d3d11rhi\private\d3d11vertexdeclaration.cpp:97]
UE4Editor_RHI!FDynamicRHI::CreateVertexDeclaration_RenderThread() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rhi\private\rhicommandlist.cpp:1972]
UE4Editor_RHI!FRHICommandListImmediate::CreateVertexDeclaration() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rhi\public\rhicommandlist.h:2626]
UE4Editor_ShaderCore!RHICreateVertexDeclaration() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rhi\public\rhicommandlist.h:3503]
UE4Editor_ShaderCore!FVertexFactory::InitDeclaration() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\shadercore\private\vertexfactory.cpp:301]
UE4Editor_Engine!FInstancedStaticMeshVertexFactory::InitRHI() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\engine\private\instancedstaticmesh.cpp:465]
UE4Editor_RenderCore!FRenderResource::InitResource() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rendercore\private\renderresource.cpp:33]
UE4Editor_RenderCore!TGraphTask<`BeginInitResource'::`2'::EURCMacro_InitCommand>::ExecuteTask() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\core\public\async\taskgraphinterfaces.h:784]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\core\private\async\taskgraph.cpp:650]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\core\private\async\taskgraph.cpp:559]
UE4Editor_RenderCore!RenderingThreadMain() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:325]
UE4Editor_RenderCore!FRenderingThread::Run() [d:\build\++ue4+release-4.17+compile\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:459]
UE4Editor_Core!FRunnableThreadWin::Run() [d:\build\++ue4+release-4.17+compile\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 to Questions & Answers just mention UE-50348 in the post.

4
Login to Vote

Fixed
ComponentTools
Affects Versions4.17.24.18
Target Fix4.19
Fix Commit3882510
Main Commit3990065
Release Commit3882510
CreatedSep 26, 2017
ResolvedFeb 14, 2018
UpdatedApr 27, 2018