TriAxis-Games / RealtimeMeshComponent

Unreal Engine 5 plugin component for rendering runtime generated content.
https://rmc.triaxis.games/
Other
1.56k stars 410 forks source link

Flickering/Crash when updating URealtimeMeshSimple #242

Closed 1polygon closed 1 year ago

1polygon commented 1 year ago

https://user-images.githubusercontent.com/1051151/223216026-53c3afec-11d1-48e7-a98a-b1acab18dfb1.mp4

When updating the mesh using UpdateSectionMesh it sometimes disappears for a frame or the editor crashes. Also there's a short freeze on the first update.

Here is how i create the RealtimeMeshComponent on BeginPlay of a SceneComponent:

RealtimeMeshComponent = NewObject<URealtimeMeshComponent>(GetOwner());
RealtimeMeshComponent->RegisterComponent();
RealtimeMeshComponent->SetMaterial(0, Material);

And here is how i create/update the URealtimeMeshSimple on the game thread:

FRealtimeMeshSimpleMeshData MeshData;
MeshBuilder->Build(Data, Size - 1, MeshData);

if (!IsValid(RealtimeMesh))
{
    RealtimeMesh = RealtimeMeshComponent->InitializeRealtimeMesh<URealtimeMeshSimple>();
    MeshSectionKey = RealtimeMesh->CreateMeshSection(0, FRealtimeMeshSectionConfig(ERealtimeMeshSectionDrawType::Dynamic, 0), MeshData, true);
}
else
{
    RealtimeMesh->UpdateSectionMesh(MeshSectionKey, MeshData);
}

Crash report:

Assertion failed: (Offset + Size) == InOther->Offset [File:D:\build\++UE5\Sync\Engine\Source\Runtime\RHICore\Private\RHIPoolAllocator.cpp] [Line: 147]

UnrealEditor_RHICore
UnrealEditor_RHICore
UnrealEditor_RHICore
UnrealEditor_D3D12RHI
UnrealEditor_D3D12RHI
UnrealEditor_RHI
UnrealEditor_RHI
UnrealEditor_RHI
UnrealEditor_RHI
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_RenderCore
UnrealEditor_Core
UnrealEditor_Core
kernel32
ntdll

Plugin version 2c219aa09d300a4f5365a76f3412f32a5c522cdf UE 5.1

Koous61 commented 1 year ago

I have same issue

Koderz commented 1 year ago

I believe this has been fixes in the latest version. If not feel free to reopen this issue or create a new one!

Thanks, Koderz

1polygon commented 1 year ago

Thanks for the update!

Unfortunately I still encounter the same issue using v5.0.5 with ue 5.2. This is the project: https://github.com/1polygon/ue5-voxel/tree/ue-5.2-dev And here is the part where the mesh is updated: https://github.com/1polygon/ue5-voxel/blob/c765dadc5bfea9d7c9a6c270aaff6ed3a5b235f1/Source/Voxel/Private/VoxelChunk.cpp#L70

I noticed that it works fine when updating vertex colors without changing the vertex/triangle count.

Koderz commented 1 year ago

@1polygon This issue is mostly fixed I think in latest, but I think there is a random outstanding issue that I've only replicated once so far.