Spawning/Destoying actors in a separate thread

Hi guys,
I posted this on the forums but didn’t get any response so thought i’d try here. Any advice on this would be greatly appreciated.

I’m having a bit of trouble trying to find some up to date info on this. Since 4.8 I believe that UObjects are thread safe however I wasn’t sure if this also applies to actors? I’ve been doing some tests and spawning anything under 1000 actors on a separate thread seems to be ok (i have to disable ticking initially) but when doing much more than that I run into issues in the Editor (not always in the same place though!). Seems to be in the Slate system and from what I can gather from the disassembly and looking at the memory it looks like memory is being cleared (however my asm debugging is very rusty so could be wrong).

Crashes in a stand alone game happen much less frequently and I have to spawn a much larger number of objects (> 20,000 usually, much more than i actually need). It’s also in a different place

So just looking for some advice. Info from around last year generally suggests that this sort of thing shouldn’t be done but I wasn’t sure if the 4.8 changes meant things were different now. I’ve also read that modifying actors outside the main thread is ok as it’s done regularly internally but haven’t been able to confirm this. Being able to spawn and destroy objects on a separate thread would REALLY make my project easier to work with and much more performant.

For the mulithreading I’m using a similar method to Rama’s multithreading tutorial (A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums) so using FRunnable, FRunnableThread etc.

Cheers,
Harley.

Hello! Could you please share some info about how you manage to spawn actors in thread?
When I do so, ue4 is throwing an exception at me at this line.

check(IsInGameThread() || HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject) || IsPostLoadThreadSafe() || IsA(UClass::StaticClass()))

Actor spawning needs to happen on the game thread, as it’s not thread safe right now. Hence, the IsInGameThread() assert

Are there any plans or works at epic games to make actor spawning thread safe?
This stuff could really help improve performance.

It’s been discussed but I don’t know of a timeline

Hi Unteroid,
From memory I ended up modifying the IsInGameThread() function so that it accepted the id of the thread i created.

It’s been a couple of years and v4.15 now, can we spawn stuff in another thread yet??

Is actor spawning thread safe yet? If not, it should be implemented.