Duplicating skeletal mesh causes error without editor

I haven’t been working on my project for some time (since before 5.0). I recently ported everything to 5.1. In Editor-builds everything works fine now, but not without the editor.

In my program, I make copies of a skeletal base mesh for characters and procedurally change vertex and bone data to create “morphed” variations. But now, the mere DuplicateObject(Mesh, …) causes an assertion, if it’s not an editor build:

Assertion failed: RenderSection.DuplicatedVerticesBuffer.DupVertData.Num() [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshLODRenderData.cpp] [Line: 198]

This is the engine code:

// DuplicatedVerticesBuffer is used only for SkinCache and Editor features which is SM5 only
    if (IsGPUSkinCacheAvailable(GMaxRHIShaderPlatform) || IsFeatureLevelSupported(GMaxRHIShaderPlatform, ERHIFeatureLevel::SM5))
	{
		const bool bSkinCacheNeedsDuplicatedVertices = GPUSkinCacheNeedsDuplicatedVertices();
		for (auto& RenderSection : RenderSections)
		{
			if (bSkinCacheNeedsDuplicatedVertices)
			{
				// No need to discard CPU data in cooked builds as bNeedsCPUAccess is false (see FDuplicatedVerticesBuffer constructor), 
				// so itd be auto-discarded after the RHI has copied the resource data. Keep CPU data when in the editor for geometry operations.
				check(RenderSection.DuplicatedVerticesBuffer.DupVertData.Num());
				BeginInitResource(&RenderSection.DuplicatedVerticesBuffer);
			}
			else
			{
#if !WITH_EDITOR
				// Discard CPU data in cooked builds. Keep CPU data when in the editor for geometry operations.
				RenderSection.DuplicatedVerticesBuffer.ReleaseCPUResources();
#endif
			}
		}
	}

Apparently, some mesh data is missing when initializing the render data during the duplication - duplicate vertices. It’s a bit absurd, because I just want a copy of the mesh. Nothing should have to be recomputed at all.

I tried disabling “support raytracing” of the mesh and setting its (only) LODinfo’s bAllowCPUAccess to true and SkinCacheUsage to disabled and recooked the content. But the error is always the same.

So, how can I duplicate a skeletal mesh at runtime in no-editor builds now??

Same crash here in 5.1.1. Works fine in-editor, crashes in distributed build. Funny enough, it only happens when connecting to a dedicated server. When running in standalone, it works fine…

[2023.07.27-18.10.26:906][634]LogWindows: Error: === Critical error: ===
[2023.07.27-18.10.26:906][634]LogWindows: Error: 
[2023.07.27-18.10.26:906][634]LogWindows: Error: Assertion failed: RenderSection.DuplicatedVerticesBuffer.DupVertData.Num() [File:F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMeshLODRenderData.cpp] [Line: 198] 
[2023.07.27-18.10.26:906][634]LogWindows: Error: 
[2023.07.27-18.10.26:906][634]LogWindows: Error: 
[2023.07.27-18.10.26:906][634]LogWindows: Error: 
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735f38fd4 vSide-Win64-DebugGame.exe!FSkeletalMeshLODRenderData::InitResources() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMeshLODRenderData.cpp:198]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735f3b1db vSide-Win64-DebugGame.exe!FSkeletalMeshRenderData::InitResources() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMeshRenderData.cpp:635]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735ead696 vSide-Win64-DebugGame.exe!USkeletalMesh::InitResources() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMesh.cpp:901]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735e9dbb4 vSide-Win64-DebugGame.exe!USkeletalMesh::FinishPostLoadInternal() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMesh.cpp:3255]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735fa3492 vSide-Win64-DebugGame.exe!USkinnedAsset::PostLoad() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkinnedAsset.cpp:58]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735eb2417 vSide-Win64-DebugGame.exe!USkeletalMesh::PostLoad() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\SkeletalMesh.cpp:3143]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7310092c2 vSide-Win64-DebugGame.exe!UObject::ConditionalPostLoad() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\CoreUObject\Private\UObject\Obj.cpp:1117]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff731148dbd vSide-Win64-DebugGame.exe!StaticDuplicateObjectEx() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2919]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff731147913 vSide-Win64-DebugGame.exe!StaticDuplicateObject() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:2745]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff730560abe vSide-Win64-DebugGame.exe!DuplicateObject<USkeletalMesh>() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectGlobals.h:1690]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7305b7a57 vSide-Win64-DebugGame.exe!AStandardModularCharacter::MergeMeshes() [F:\vSide\vSide-UE5-Source-5.1\Source\vSide\Characters\StandardModularCharacter.cpp:52]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7305d9a63 vSide-Win64-DebugGame.exe!AStandardModularCharacter::Rebuild() [F:\vSide\vSide-UE5-Source-5.1\Source\vSide\Characters\StandardModularCharacter.cpp:20]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7305c7701 vSide-Win64-DebugGame.exe!AStandardCharacter::OnConstruction() [F:\vSide\vSide-UE5-Source-5.1\Source\vSide\Characters\StandardCharacter.cpp:82]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff734dc2147 vSide-Win64-DebugGame.exe!AActor::ExecuteConstruction() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\ActorConstruction.cpp:919]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff734dc5529 vSide-Win64-DebugGame.exe!AActor::FinishSpawning() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\Actor.cpp:3745]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff734dd9e44 vSide-Win64-DebugGame.exe!AActor::PostSpawnInitialize() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\Actor.cpp:3687]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7357d6bb4 vSide-Win64-DebugGame.exe!UWorld::SpawnActor() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\LevelActor.cpp:729]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7357d7afa vSide-Win64-DebugGame.exe!UWorld::SpawnActorAbsolute() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\LevelActor.cpp:425]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735a001ee vSide-Win64-DebugGame.exe!UPackageMapClient::SerializeNewActor() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\PackageMapClient.cpp:670]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735420de9 vSide-Win64-DebugGame.exe!UActorChannel::ProcessBunch() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\DataChannel.cpp:2926]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff73543084d vSide-Win64-DebugGame.exe!UActorChannel::ReceivedBunch() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\DataChannel.cpp:2896]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff73543456c vSide-Win64-DebugGame.exe!UChannel::ReceivedNextBunch() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\DataChannel.cpp:996]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7354363b4 vSide-Win64-DebugGame.exe!UChannel::ReceivedRawBunch() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\DataChannel.cpp:649]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff73594854b vSide-Win64-DebugGame.exe!UNetConnection::ReceivedPacket() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\NetConnection.cpp:3459]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735949903 vSide-Win64-DebugGame.exe!UNetConnection::ReceivedRawPacket() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\NetConnection.cpp:1810]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72f7574a4 vSide-Win64-DebugGame.exe!UIpNetDriver::TickDispatch() [F:\Unreal Engine\UE5.1\Engine\Plugins\Online\OnlineSubsystemUtils\Source\OnlineSubsystemUtils\Private\IpNetDriver.cpp:1080]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff73597e94c vSide-Win64-DebugGame.exe!TBaseUObjectMethodDelegateInstance<0,UNetDriver,void __cdecl(float),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:618]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7314fc4cd vSide-Win64-DebugGame.exe!TMulticastDelegate<void __cdecl(float),FDefaultDelegateUserPolicy>::Broadcast() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:975]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff735814557 vSide-Win64-DebugGame.exe!UWorld::Tick() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1378]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff73555a457 vSide-Win64-DebugGame.exe!UGameEngine::Tick() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Engine\Private\GameEngine.cpp:1778]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72dfe9dff vSide-Win64-DebugGame.exe!FEngineLoop::Tick() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5369]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72e0033ce vSide-Win64-DebugGame.exe!GuardedMain() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Launch\Private\Launch.cpp:202]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72e0034aa vSide-Win64-DebugGame.exe!GuardedMainWrapper() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:107]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72e0063e6 vSide-Win64-DebugGame.exe!LaunchWindowsStartup() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:244]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff72e017e34 vSide-Win64-DebugGame.exe!WinMain() [F:\Unreal Engine\UE5.1\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:283]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ff7375b476a vSide-Win64-DebugGame.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ffa90db7614 KERNEL32.DLL!UnknownFunction []
[2023.07.27-18.10.26:906][634]LogWindows: Error: [Callstack] 0x00007ffa92a026b1 ntdll.dll!UnknownFunction []
[2023.07.27-18.10.26:906][634]LogWindows: Error: 
[2023.07.27-18.10.26:915][634]LogExit: Executing StaticShutdownAfterError
[2023.07.27-18.10.26:915][634]LogWindows: FPlatformMisc::RequestExit(1)
[2023.07.27-18.10.26:915][634]LogWindows: FPlatformMisc::RequestExitWithStatus(1, 3)
[2023.07.27-18.10.26:915][634]LogCore: Engine exit requested (reason: Win RequestExit)