Issue when destroying objects (bug introduced since 21st Sept 2018)


#1

On Friday, my project was working fine. Upon resuming work on it this morning, I quickly found my scenes were no longer being destroyed correctly. Code such as this was causing an error:

this.on('destroy', this.onDestroy);
this.entity.collision.on('collisionstart', this.onContactStart, this);

GameObject.prototype.onDestroy = function()
{
    this.off('destroy', this.onDestroy);   
    this.entity.collision.off('collisionstart', this.onContactStart, this);
}

The error: “Uncaught TypeError: Cannot read property ‘off’ of undefined”

In the onDestroy function, this.entity no longer has a collision object from which to remove the event. As I say, this was working fine until this morning, and many scripts in my project rely on it.

At the end of every day, I export my project and save it into SVN. Out of curiosity, I exported a new version with this problem in it and just swapped out the playcanvas-stable.min.js file with the one from Friday’s export, and it worked fine. So something changed in the meantime has caused this issue. The files are indeed 1kb different.

I’ve made a sample project here: https://playcanvas.com/project/578084/overview/bugtest

Any advice would be greatly appreciated, thank you.


#2

While this is being looked at, you can temporary use an older version of the engine in the launch window: https://developer.playcanvas.com/en/user-manual/scripting/custom_engine/

That should keep you going in the meantime.


#3

This now seems to be happening regardless of what version of the engine I set it to:

https://launch.playcanvas.com/647408?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.7.0.min.js (this is the same sample project as linked above)


#5

We are going to look into this thank you.