Rendering thread safety?...
Ok, so I've been having this crash bug that's been driving me insane for months now (there is in fact very little sanity left I'm afraid). I spent hours and days trying to find the cause. Then it seemed like it solved itself. Then it came back. Then it solved itself...
I've been reading all kinds of engine code, but for the first time now I think I may have an idea of what's going on. So here is what I'm doing:
I made this character morphing system that can modify a character's shape at runtime. It can also add and remove pieces of clothing. Every character's mesh is a copy of a base mesh that gets procedurally changed: vertex-data and bone-transforms get modified, sections, chunks and materials get added or removed and skeletal mesh resources get re-initialized.
Most of the time everything works fine. But sometimes I get a crash when changing the clothing, which is probably connected to the addition/removal of the clothing's material(s) from/to the character mesh. It seems to occur completely randomly. But now I realised that certain code that should be executed, because it's part of the morphing process, never gets reached before the crash. Instead I get an engine error from rendering before the whole process has finished.
I don't know much about multi threading, but this is the only way I can make any sense of it. Can someone confirm that this may actually be the problem? Is there something I can do to make sure that the mesh I am modifying is not being rendered in this very milisecond?
asked Apr 20 '16 at 04:00 PM in Rendering
I am not 100% sure the crash won't come back, but I think (just maybe) FSuspendRenderingThread may have done the trick.
answered Apr 21 '16 at 11:15 PM
I am getting different crash reports. I guess it depends on where the render thread is at when I modify the mesh. But this call stack is a typical one:
I had to post as answer because of the character limit for comments...
answered Apr 21 '16 at 05:49 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here