question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Child entities don't inherit scene from parent, logs warning when killed

See original GitHub issue

It appears that child entities do not inherit this.scene from its parent. I first noticed this when killing an actor with children and getting the following warning:

Cannot kill actor, it was never added to the Scene

After digging into it I noticed it was the child entity logging the warning, as this.scene was null here:

https://github.com/excaliburjs/Excalibur/blob/730d621805d32104c18dc7ca8d9e97c7f212bb2b/src/engine/Actor.ts#L795-L804

If the child entities aren’t truly killed it’s possible this might be a memory leak, but I haven’t dug much further.

Steps to Reproduce

repro: https://codesandbox.io/s/exaclibur-child-entities-bug-5r0w3e?file=/src/index.js

  • Add children to an actor via actor.addChild()
  • Kill the actor
  • See the warning in console

Expected Result

Children should inherit scene from parent and no warning log should occur when killed

Actual Result

Children do not inherit scene and a warning is logged when parent is killed

Environment

  • browsers and versions: Chrome 103.0.5060.114
  • operating system: macoS 12.4
  • Excalibur versions: 0.27

Current Workaround

None

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisk-7777commented, Jul 23, 2022

Thanks for the fix! It’s amazing the speed of development on this project

1reaction
chrisk-7777commented, Jul 20, 2022

I was just about to raise something similar, so good timing!

My suggestion was to improve the warning message to include the actor’s name to help narrow down the warning when it does pop up. But a fix to the underlying issue would also be ace.

Something like:

this.logger.warn(`Cannot kill actor ${this.name}, it was never added to the Scene`); 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Inheritance and the prototype chain - JavaScript | MDN
When it comes to inheritance, JavaScript only has one construct: objects. Each object has a private property which holds a link to another ......
Read more >
Hiding inherited public variable in the inspector? - Unity Forum
Is it possible to make a public inherited variable to not show up in the inspector? Its only needed in the parent class...
Read more >
Inheritance of Febrile Seizures in Sudden Unexplained Death ...
Sudden unexplained death in toddlers has been associated with febrile seizures, family history of febrile seizures, and hippocampal anomalies.
Read more >
Estate Planning Horrors: Don't Let Strangers Snatch Your ...
Under it, property goes first or in major part to a spouse then secondly to children and their descendants. When there are no...
Read more >
How to make child process die after parent exits?
The child process is spawned in the background. The shell waits for a newline (or an EOF) then kills the child. When the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found