Download

Cloth cause actor to spawn 50 times slower

Hello,

I noticed that some of my actors spawn very quickly and some very slowly.

The code is a simple call to SpawnActor:


YagLog(FString::Printf(TEXT("AYagUIBranch::FillCircle spawning %s"), *BPChildren*->GetName()), FColor::Red);

(*ThisCircleChildren).Add(GetWorld()->SpawnActor<AActor>(BPChildren*, GetActorLocation() + ThisCircleChildLocation, ThisCircleChildRotation, SpawnParams));

YagLog(FString::Printf(TEXT("AYagUIBranch::FillCircle %s spawned"), *BPChildren*->GetName()), FColor::Red);

SpawnActor is here wrapped by a logging function.

Here are the results:


[2018.09.23-10.25.29:881][963]LogTemp: Warning: AYagUIBranch::FillCircle spawning BP_FemaleFighter_C
[2018.09.23-10.25.29:883][963]LogTemp: Warning: AYagUIBranch::FillCircle BP_FemaleFighter_C spawned
[2018.09.23-10.25.29:883][963]LogTemp: Warning: AYagUIBranch::FillCircle spawning BP_HXFantasyCharacter01_C
[2018.09.23-10.25.29:974][963]LogTemp: Warning: AYagUIBranch::FillCircle BP_HXFantasyCharacter01_C spawned

As you can see, the FemaleFighter takes 2 ms to spawn, while the HXFantasyCharacter01 takes 90 ms.

This is very repeatable.

I made tests with many actors (all from the same class, so exactly the same number of components, etc.) and the only significant difference i could noticed is that the fast ones don’t use the cloth feature, while the slow ones have a skeletal mesh with cloth.

Moreover, the slowing seems to depends on the cloth surface: the larger the cloth, the slower the spawning (no cloth ~2 ms, small cloth ~50 ms, large cloth ~100 ms).

I understand that Spawning is a costly call, but going from 2 to 90 ms doesn’t seem quite normal.

And since i’m spawning about 30 of them at a time, i get a ~3 seconds freeze each time i spawn the clothed ones.

I don’t know the guts of the engine, is that expected ?
Would there be a workaround ?

Thanks
Cedric

I’m seeing the same thing. Actor spawns much slower with cloth, causing a noticeable hitch. Did you ever determine a workaround?

No, i still have to live with it :frowning:

What Engine version are you guys on?

I follow all UE4 versions, so i’m currently in 4.23.1, soon to go to 4.24 when it’s stable enough.

We just updated to 4.24.2 and the problem not only is not resolved, but it may have gotten even worse.

Does it only happen on the first time you call SpawnActor or every time?
I could imagine preloading the mesh asynchronously might help here.

Every time, so spawning more actors has a cumulative effect.

maybe you can cheat and have a bunch of spawned in cloths hiding somehwere in the level, then when you spawn an actor, attach the cloth to the actor as a component then when you de-spawn or kill the actor, just remove the cloth and make it not visible.