TriAxis-Games / RealtimeMeshComponent

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

FRenderResource's `IsInRenderingThread`-check fails during generation? #241

Closed sfla closed 10 months ago

sfla commented 1 year ago

I'm having a hard time investigating a crash(?) to find out if it's my own wrong-doing, or if this is an actual bug. It's time consuming to reproduce, so before I spend a lot of time diving into this I'd most like to know if this is a known issue. I'm testing RMCv5 for the creation of terrain which will automatically generate or destroy themselves based on the distance to the player position, sort of a custom LOD system. Everything works for the most part - until I move backwards in a specific scenario. For some reason, when I trigger a terrain-node behind me to update while moving backwards, I hit an assertion in the engine.

Specifically at RenderResource.cpp:86 in the function void FRenderResource::InitResource(){. The failing assertion is check(IsInRenderingThread()).

The call-stack reveals that the previous call is in RealtimeMeshSectionGroupProxy.cpp:300: https://github.com/TriAxis-Games/RealtimeMeshComponent/blob/2c219aa09d300a4f5365a76f3412f32a5c522cdf/Source/RealtimeMeshComponent/Private/RenderProxy/RealtimeMeshSectionGroupProxy.cpp#L299-L300 This has happened to me on both Thread-7-[Foreground Worker #0] and Thread-8-[Foreground Worker #1], if that's relevant. I do use threading to generate my MeshData, but as far as I know, I only ever directly execute RMC-code on GameThread, so I don't believe these are my threads.

I'm somewhat able to reproduce this predictably, but it takes some time. Since it only happens when I move backwards, I assume it has something to do with the fact that whatever it tries to render is currently outside of my viewport? I may be wrong about that though, as two times I swear it happened just because I simply stopped moving forward.. I have no idea how to approach it, even if I found a faster way to reproduce it.

Any thoughts?

image image

(Using UE 5.0.1 btw, not 5.1)

Koderz commented 1 year ago

Hey @sfla Is this still an issue? I've never been able to repro anything close to it.

sfla commented 1 year ago

@Koderz I don't know, I never got to the bottom of it, and reverted back to RMC4.

Another potentially crucial piece of information is that all the terrain actors are spawned way the fuck out from world center, and having LWC enabled (though all vertex-data is within regular ranges). A terrain-chunk (RMC actor) is spawned at approximately earth-radius, and the terrain mesh is offset from that.

My implementation at that time was "educational" and just to test RMC5 benchmarked vs RMC4. I sadly don't have the time to try this again for a rather long while. You may close this if it simply doesn't make sense and no one else have experienced anything like it. May very well be my own faulty implementation, but I felt I was pretty thorough on my side at the time.. 🤷‍♂️

Koderz commented 10 months ago

Enough has changed in RMC 5 that I don't think is is going to directly apply at this point. If I'm wrong, feel free to reopen this or post a new bug!

Thanks, Chris