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]LogTemp: Warning: AYagUIBranch::FillCircle spawning BP_FemaleFighter_C [2018.09.23-10.25.29:883]LogTemp: Warning: AYagUIBranch::FillCircle BP_FemaleFighter_C spawned [2018.09.23-10.25.29:883]LogTemp: Warning: AYagUIBranch::FillCircle spawning BP_HXFantasyCharacter01_C [2018.09.23-10.25.29:974]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 ?