First Spawn of Actor with SplineMeshComponent is slow (especially on Android)


I noticed this since a little while ago and did quiet a bit of research on why this is happening, but I dont think I understand why this is happening.

When I spawn an actor with a splinemeshcomponent (or even staticmeshcomponent), which has a mesh set either through the blueprint or directly in c++, the first spawn always slows down the game for a little while. When I then call to destroy the actor and spawn it again a few seconds later the spawn happens much faster withouth any slowdown. Also when I force garbage collection and wait long time the 2nd spawn of this actor always happens much faster.

And this only happens when a mesh is assigned to the component. The mesh is use for testing is the simple fishbody mesh from the content example sample project. (First I thought it is the material which was “too expensive” for Android, but even with the default material")

I set many breakpoints in Actor.cpp, SplineMeshComponent.cpp, UObject.cpp, ConstructionHelpers.h, trying to find out what is different on the 2nd spawn, but nothing seems to be different.

Here is also other things which I tried:

  • Loading the mesh assync and not trough construction script
  • Spawning the actor deffered and set the mesh before finalizing the spawn
  • Setting the mesh not in constructor but inside postinitializecompomponents
  • Using other template versions for spawning the actor
  • Using Blueprints to set the mesh there
  • Trying different Lighting modes from dynamic to static and even everything unlit with only emmissive materials.

At this point I am out of ideas besides spawning and destroying the actor once at begin play.

The code below I use inside the CDO of the Actor Class I spawn:

//Constructing Mesh static (only at game start)
static ConstructorHelpers::FObjectFinder<UStaticMesh> ArrowMesh(TEXT("StaticMesh'/Game/Props/FishBody.FishBody'"));
	if (ArrowMesh.Object) {
		ArrowMeshC = (UStaticMesh*)ArrowMesh.Object;

//Init Root
StuffRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("StuffRoot"));
RootComponent = StuffRoot;

//Init SplineMeshComponent
Arrow1P = ObjectInitializer.CreateDefaultSubobject<USplineMeshComponent>(this, TEXT("ArrowSplineMesh"));	
Arrow1P->SetRelativeScale3D(FVector(4, 1, 1));
Arrow1P->StaticMesh = ArrowMeshC;
Arrow1P->bCanEverAffectNavigation = false;
Arrow1P->bGenerateOverlapEvents = false;
Arrow1P->AttachParent = RootComponent;


In the meantime I think I found out that this is mainly Android/OpenGL ES related.

I made an answerhub post here: