[Editor BUG] Random error appears when manipulating with templates

Hello everyone!

We’ve been facing some random editor issue when manipulating with entities instantiated from templates.
Here’s the listing from the console:

============================================

Attempting to delete the entity that caused the problem, we get following error:


=======================================

All this together is preventing the project from being loaded:


That happened 3 or four times in a week with different entities and templates.
This is quite common issue, as I’ve seen the same error happened to another project of another developer:

Hi @Igor,

Does this happen only when launching from the editor before the application starts, or doe sit also happen after the app is loaded and you move things around in the editor?

The only possibility to fix it is restoring a last breakpoint (which is always painful because of losing all the progress, you know…)

Could you guys take a look at that? E.g. suggest a snippet that could help to remove all these broken entities via the editor API or in any other way?

P.S. I’ve tried to delete that entity via

let bugged = editor.entities.root.filter(entity => entity.viewportEntity._guid === "529aef2d-930d-46ea-a620-fa4b0ef91bfc")[0];

editor.entities.delete([bugged]).then(r => console.log("Result: ", r)).catch(e => console.log("Error ", e));

Unfortunately, that causes the same error (api.js:1027 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘get’)
at api.js:1027)

I can’t even launch the app via launch.playcanvas.com/PROJECT_ID

Out of curiosity, are you preloading your template assets? It could be that the template asset itself, or pieces of it have not been loaded by the time it’s being called to be instantiated and added to the graphNode.

The error is thrown with preload checkbox set and unset. As well as with both enabled/disabled broken entities.

We are aware of the issue and have a fix in review to prevent it from happening with the reproducible stops that we have so far.

As it has already happened so far in a couple of your projects, please use these steps to resolve it: Cannot find child entity of parent "Root" - Editor error, can't delete entities

If you are having issues with the steps as it seems like you have a few, please do let us know and we will help as much as we can.

For the short term until the fix is release, do not use the duplicate command for entities and use copy and paste instead.

Hey @yaustar, thank you for the super-fast reply and a possible way to fix the issue!

Indeed, I remember we were using duplicate command sometimes and it might be the reason of the issue.