Branch: tested with promoted branch (66a699f)
Build version: 4.12.0-0+UE4
Detailed description of the issue:
In the construction script of an actor in my level, I create some child actors using an “Add Child Actor Component” node and store the actors for later usage in an array variable. But since I updated from 4.10.2 to the promoted branch, I get these error messages, when I play the level in the editor and it tries to use the child actors saved in the array variable:
Error Cannot access
‘DESTROYED_SymbolBlock_C_CHILDACTOR_21’.
It is pending kill. Property:
‘CallFunc_Array_Get_Item3’ from node
Set Symbol in graph ‘ChooseNewSymbols’
in blueprint MainBoard
Error Cannot access
‘DESTROYED_SymbolBlock_C_CHILDACTOR_19’.
It is pending kill. Property:
‘CallFunc_Array_Get_Item3’ from node
Set Symbol in graph ‘ChooseNewSymbols’
in blueprint MainBoard
[…]
I debugged the code and compared the source of 4.10.2 and the promoted branch and found that this code was added inside Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp: UActorComponent::RegisterComponentWithWorld():
if (!bHasBeenCreated)
{
OnComponentCreated();
}
The problem with child actor components here is, that UChildActorComponent overrides this method in Engine\Source\Runtime\Engine\Private\Components\ChildActorComponent.cpp like this:
void UChildActorComponent::OnComponentCreated()
{
Super::OnComponentCreated();
CreateChildActor();
}
Which leads to the child actor to be killed / marked for pending kill:
void UChildActorComponent::CreateChildActor()
{
// Kill spawned actor if we have one
DestroyChildActor();
This wouldn’t be a problem, if the construction scripts would be called in PIE mode, but the bRerunConstructionScripts parameter of ULevel::IncrementalUpdateComponents() is false and thus they are not called. As a result, the array (already initialized by the editor) contains references to child actors marked as pending kill.
Here are the blueprints for reference: