Spawn Particle at Location Performance Hiccup

Problem

I get a small but noticeable hiccup in performance when I spawn a particle system from C++. This is in essence what the spawn function looks like:

UGameplayStatics::SpawnEmitterAtLocation(this, BotchedEffect, Hits[i].ImpactPoint, FRotator::ZeroRotator);

BotchedEffect is a pointer to the asset that I’ve set in the Editor.

I’ve also tried using TAssetPtr with SimpleAsyncLoad to load the asset on start and then call .Get() to get the pointer and spawn the asset but that also has a hiccup.

Details from “stat unitgraph”

42418-2015-05-12_14-15-022.png

The above images show the two different events. (1) is the first spawn with the hiccup (2) is the second spawn and all others after that, that do not cause a hiccup.

Assumption

I feel like the issues stems from the concept that the asset isn’t loaded when I try to spawn it so the engine has to load the asset into memory and spawn it.

Question

Any thoughts on why this might be happening? Is there a proper way to spawn assets without a hiccup? Specifically particle systems, but in general all things.

I am seeing this exact problem as well. Any additional info would be great.

Yeah this is an issue I’m still seeing :frowning:

I’ll post here if I ever find anything!

If the asset is not loaded when you call .Get(), the game will pause until it is loaded before continuing.

Docs are here:

You can use FindObject to see if an object is in memory or not

I have tested the TAssetPtr Get() with 4.8.2 and found it no longer has a hickup. I just updated all my code and it now works. I will report back if anything changes. Thank you.

I’m still seeing a slight spike the first time I call Get() on the item. I check to see if the asset is loaded so I know it’s in memory. Is this expected? It doesn’t hurt the frame rate but I feel like this is abnormal?

The second spike is the second time I call it which is faster. I assumed using AsyncLoads would remove that initial spike time.

50831-2015-07-20_13-12-08.png

Is that on the Get()? or on the SpawnActor? Spawning an actor has costs associated with it, so it is not surprising to see some amount of overhead

I tried the Get() and it has almost no visible impact on the graph, which is great.

So It must be the spawning actor cost, which looks like this. In the following image I spawned the actor twice. But only the first really affected the graph. That spike put me at 22ms. That seems like a bit much no?

50866-2015-07-20_20-52-57.png

Why is the first spawn so costly?

Is there a way to soften this cost somehow. It seems to cause a hicup when I spawn the particle for the first time.

Not sure without digging in. Especially with the subsequent spawns not costing the same amount. If they did, then I’d say something in your setup of the particle system, say maybe a lot of pre-warmed particles

Hi Joe,

After profiling this intensely I found that the issues was just my perception of the graph. I was testing it at an unlocked framerate and thus the difference was visible. After capping it at 60fps there is almost no visible impact at all.

Sorry for the undue trouble!

Hey guys, I’m a little late to this discussion but I think I’m having the exact same problem with my project. I’m designing a mobile game, and specifically on android and iOS there is a noticeable hiccup in performance when particles and actors are spawned. It won’t slow down on a windows build, but on mobile hardware the impact in performance will hang the game for almost a full second at times. Wondering how you used the Asyc loading to avoid this issue? I’ve experimented with a few but none have worked yet :frowning: