[SOLVED] Problems loading scripts after latest update

Since the latest version of playcanvas 1.65.3 It looks like I have trouble loading some scripts.

In the project I preload only a few assets and then the others that have a specific tag. and when everything is loaded I have to press a button to continue to the game. But now when I press the button I get an error message that there are problems loading scripts and that I need to look in the console and then I see the error that you can see on the image below.

In a previous version of playcanvas it still works.

Could you please click on this

Screenshot 2023-08-29 at 10.38.06

and show us the source code that is shown? I’m looking at that and not entirely sure what the problem is.

herre you go :slight_smile:

I see, thanks. This seems more complex than I expected, would you be able to put some simple repro test together for us?

I will try to create a smaller project later this week for you guys to test it

1 Like

Hi @mvaligursky my colleague TimothyGrave and I have the same issue with different projects.
I’ve added you to one of our repo’s (gardenbloom) to check it out. I also think the issue I’ve described in the discord regarding not being able to find a 3d asset’s rootbone might be related as well,

so I’ve invited you to that project aswell (butterfly) if you’d like to check it out.

@mvaligursky I was wondering if there was any progress on this issue.


Hey there, I wanted to let you know the issue is now resolved! slimbuck checked out our projects and with this latest pull request our project broke EventHandler: refactor, comment and optimize by Maksims · Pull Request #5501 · playcanvas/engine · GitHub

We used code injection in the eventHandler to ensure all events get turned off in the right order but we were accessing callbacks directly through the object as _callback[“name”] with the latest engine the eventHandler is now a map instead of an object so we should use callback.has, callback.set & get

I don’t know if in the latest release the order of event execution can still be out of chronological order so for now I’ve refactored our injection, if anyone else has the same issue here is the script for future reference

pc.extend(pc.EventHandler.prototype, {
    off: function (name, callback, scope) {
        if (name) {
            // if we are removing a callback from the list that is executing right now
            // ensure we preserve initial list before modifications
            if (this._callbackActive.has(name) && this._callbackActive.get(name) === this._callbacks.get(name))
                this._callbackActive.set(name, this._callbackActive.get(name).slice());
        } else {
            // if we are removing a callback from any list that is executing right now
            // ensure we preserve these initial lists before modifications
            for (var _iterator = this._createForOfIteratorHelperLoose(this._callbackActive), _step; !(_step = _iterator()).done;) {
                var _step$value = _step.value
                    , key = _step$value[0]
                    , callbacks = _step$value[1];
                if (!this._callbacks.has(key))
                if (this._callbacks.get(key) !== callbacks)
                this._callbackActive.set(key, callbacks.slice());
        if (!name) {
            // remove all events
        } else if (!callback) {
            // remove all events of a specific name
            if (this._callbacks.has(name))
        } else {
            var events = this._callbacks.get(name);
            if (!events)
                return this;
            var count = events.length;
            // Made sure the the order doesn't change
            for (var i = events.length - 1; i >= 0; i--) {
                if (events[i].callback !== callback)

                if (scope && events[i].scope !== scope)

                events.splice(i, 1);
            events.length = count;
            events.length = count;
            if (events.length === 0)
        return this;

    _createForOfIteratorHelperLoose: function (o, allowArrayLike) {
        var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
        if (it)
            return (it = it.call(o)).next.bind(it);
        if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
            if (it)
                o = it;
            var i = 0;
            return function () {
                if (i >= o.length)
                    return {
                        done: true
                return {
                    done: false,
                    value: o[i++]
        throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");