Description

Registration of budgeted components with the allocator fails when running in ENetMode::NM_Client.  The initialization order when running in this mode is different to Standalone net mode which ends up breaking the registration of components owned by actors that have been dropped into the level.
The usual order on PIE is:

  • USkeletalMeshComponentBudgeted::BeginPlay is called via AQAGameMode::StartPlay
    • This adds the component to the deferred registration array in the allocator
  • FAnimationBudgetAllocator::HandleWorldBeginPlay is called via UWorld::BeginPlay
    • This then registers the deferred components

But when running as a client on PIE:

  • USkeletalMeshComponentBudgeted::BeginPlay is called via AQAGameMode::StartPlay
    • Called for the server - no components are registered
  • FAnimationBudgetAllocator::HandleWorldBeginPlay is called via UWorld::BeginPlay
    • Called for the server - nothing to register
  • FAnimationBudgetAllocator::HandleWorldBeginPlay is called via UEngine::TickWorldTravel
    • Called for the client
  • USkeletalMeshComponentBudgeted::BeginPlay is called via UWorld::Tick and 
    AWorldSettings::NotifyBeginPlay
    • Called for the client
    • Because UWorld::bBegunPlay has not been set yet (it isn't set until the end of AWorldSettings::NotifyBeginPlay) we use the deferred registration path. 
    • But we've already called FAnimationBudgetAllocator::HandleWorldBeginPlay so we now never perform the registration of the deferred components

It seem that relying on UWorld::bBegunPlay leaves us with a window of time where registration of components will fail because FAnimationBudgetAllocator::HandleWorldBeginPlay has been called but UWorld::bBegunPlay has not been set.  It feels like we'd be better to set a flag in the allocator when FAnimationBudgetAllocator::HandleWorldBeginPlay is called and then choose immediate vs deferred registration based on that flag.

Steps to Reproduce
  1. Run QAGame in the editor
  2. Open the BudgetTest level
  3. In the PIE settings, set NetMode to Play As Client
  4. Start PIE
    1. Expected behaviour: budget allocator debug draw should show that the skel mesh components running on the actors are registered
    2. Actual behaviour: budget allocator debug draw shows that no skel mesh components are registered

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-198881 in the post.

3
Login to Vote

Fixed
ComponentUE - Anim - Runtime
Target Fix5.4
Fix Commit31208501
Main Commit31208536
Release Commit31208512
CreatedOct 24, 2023
ResolvedFeb 6, 2024
UpdatedMar 6, 2024
View Jira Issue