ActorComponents registered with wrong world from UWorldPartition::ApplyRuntimeCellsTransformerStack

There is a risk of actor components registering with the wrong world when reconstructed from UWorldPartition::ApplyRuntimeCellsTransformerStack. The repro case is arguably a bad usage, but it was the easiest way I found to showcase the issue.

Components registered during the construction phase can have the temporal world assigned and cached. I believe this is not an issue in most cases, but I think it is something worth flagging as it might be the only (and a new case) where the actors are constructed with a temporal world, and it could cause hard to find issues.

[Attachment Removed]

Steps to Reproduce

  • In the ThirdPersonCharacter project, create a default open world level and add a UWorldPartitionRuntimeCellTransformerISM to the stack
  • In C++, create an actor with the following code
AMyActor::AMyActor()
{
    RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
    ensureAlways(IsValid(RootComponent->GetWorld()->GetGameInstance()));
}

void AMyActor::OnConstruction(const FTransform& Transform)
{
    Super::OnConstruction(Transform);
    MySceneComponent = NewObject<USceneComponent>(this);
    AddInstanceComponent(MySceneComponent);
    RegisterAllComponents();
}

  • See ensure trigger
    [Attachment Removed]

Hi,

I created a JIRA for this issue, which can be tracked here: https://issues.unrealengine.com/issue/UE-358403. I don’t have an ETA, as priorities for bugs and features can shift at any time.

Thanks,

Ryan

[Attachment Removed]