Async spawn objects

Hello,
i’m trying to spawn 1k to 10k objects onscreen (mostly billboards) which are recovered from an external network service on a different thread.

When the thread completes the download it calls a blueprint-implemented delegate, which then cycles through the objects to spawn and actually spawns it.

My main issue is that with this number of objects, the engine struggles (it freezes for 10 or more seconds before actually displaying the billboards).

Is there a way to asynchronously spawn objects from blueprint OR c++?

Thanks,
Riccardo.

I already have a multithread architecture, the issue is that it can’t manipulate scene objects (or something that’s owned by the graphics thread); that’s the reason I spawn objects from a blueprint event that’s called from the main thread.

Here you have tutorial how to create your own threads in C++:

You need to keep in mind using multithreading on unprepared code for that might be risky and unstable and i don’t know if spawning code is ready for it. So do a lot of testing.

Then there no way or else you revamp whole spawning code if multithreading does not work. Or maybe try to hide those 10 seconds of frezee

Could you spawn this large pool of objects on startup, put them in a threadsafe / lockless queue or something, and then when you need them you can have multiple worker threads pop these already-constructed objects from the queue and initialise them with the appropriate state?

I’m in the process of trying this approach.
I just tried using a Gameplay Timer and handling there the spawning of new objects, but after 400/500 elements the framerate just drops to 1/2 fps and goes back to 60 after it reached 1k and stops.

Turns out that initializing thousands of objects with a sphere collider in the same position is really BAD.

Spawning them in a random box was the solution, since it now only takes a second or two.