x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AddChildActorComponent from construction script in PIE cause pending kill problems

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:

alt text

Product Version: UE Github Master branch
Tags:
more ▼

asked Feb 10 '16 at 09:44 PM in Bug Reports

avatar image

Grimmick
61 1 8 9

avatar image Sean L ♦♦ STAFF Feb 11 '16 at 03:17 PM

Hello,

I have attempted to reproduce your issue, but I'm not seeing any error messages when I use your blueprint setup and PIE.

Have you tried recreating a simple test in this branch without using an upgraded project? If not, could you go ahead and try and let me know if you are still seeing the same error? If you do get the same error in a clean project, please provide the repro steps so that we can reproduce it on our end.

Thank you

avatar image Grimmick Feb 11 '16 at 09:48 PM

Hi Sean,

thanks a lot for looking into this! Well, the "and it tries to use" of

when I play the level in the editor and it tries to use the child actors saved in the array variable

was not part of the reference blueprints.

You should be able to easily reproduce the error messages by adding a simple usage in the BeginPlay event of the "MainBoard" actor:

alt text

Sadly, I cannot try now, because I already fixed it for me by not calling OnComponentCreated() and for some reason Visual Studio thinks that it has to rebuild the whole engine, when I put it back into the code...

avatar image Sean L ♦♦ STAFF Feb 12 '16 at 01:29 PM

Thank you for the clarification. I have tried to reproduce this issue again using the method you suggested below, but I still have not been able to nail it down.

It sounds like you were able to resolve the issue in your current project, is that correct?

avatar image Grimmick Feb 12 '16 at 10:55 PM

Not really, I just removed the code killing the child component, with unknown consequences for the rest of the engine ;)

As you tried again without succeeding, I installed the current 4.11.0 Preview 5 (Build version: 4.11.0-2858478+++UE4+Release-4.11). I'm still able to reproduce the problem with my project.

Repro steps for a minimal test case:

  • Open the official Unreal Engine 4.11.0 Preview 5

  • Create new "blank" project without starter content

  • Create a new blueprint class based on Actor, call it Block

  • Select the floor object of the level and click on "Blueprint/Add Script" in the details tab

  • In the Floor_Blueprint blueprint editor:
    • Add a variable named "ChildActorVar" of type Actor reference

    • In the Construction Script:
      • Add a "Add Child Actor Component" node, choosing "Block" as Child Actor Class

      • Take the return value and choose "Get Child Actor"

      • Assign the child actor to the variable "ChildActorVar"

    • In Event Graph:
      • From the "Event BeginPlay" node create a "Print String" node

      • Drag the "ChildActorVar" as "Get" into the blueprint and choose "Get Actor Eyes View Point"

      • Connect the "Out Location" value with "In String" from the "Print String" node

    • Compile the blueprint

  • Play the level -> "X=0.000, Y=0.000, Z=0.000" is displayed, should be "X=0.000, Y=0.000, Z=20.000", as the floor in a blank project is at Z=20cm

  • Stop the level -> "Errors/warnings reported while playing in editor": Error Cannot access 'DESTROYED_Block_C_CHILDACTOR_6'. It is pending kill. Property: 'ChildActorVar' from node Print String in graph 'EventGraph' in blueprint Floor_Blueprint

Note: If you directly use GetDisplayName from the ChildActorVar in the event graph, there will be no error. You can also add a string var to the block and try printing this on begin play. Also errors.

No error with 4.10.2.

alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hello,

Thank for providing clear repro steps. I have been able to reproduce your issue, and have entered a bug report (UE-27008). I will provide updates on this issue as they become available.

Have a great day

more ▼

answered Feb 16 '16 at 07:46 PM

avatar image

Sean L ♦♦ STAFF
43.5k 485 152 442

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question