Problem with scheduleOnce and callFunc

TestSchedule.zip (217.5 KB)

Hi guys,

I uploaded a test project utilizing schedule once, callfunc and settimeout. Everytime you click one of the buttons, there will be 50 nodes executing either scheduleOnce, runactions’ callfunc or settimeout.

By continuously calling scheduleOnce or callfunc multiple times, there would be a very apparent frame rate issue ( this doesnt last long, only a few milliseconds on executing the methods). At the start, things seem to be ok, but as we keep calling the function, this issue comes up and gets progressively worse as the function is called up more. I think it will be apparent when you guys run the project and start clicking on the scheduleOnce button.

Settimeout seems to be working fine though, just to act as a benchmark comparison.

@slackmoehrle @nite @nantas2 help? I’m facing the same issue

An update to this issue:

Found that in CCNode.js every runAction will retain the action in an array.

In runAction(action) function:

if (CC_JSB) {
    this._retainAction(action);
    this._sgNode._owner = this;
}

In _retainAction(action) function:

_retainAction: function (action) {
        if (CC_JSB && action instanceof cc.Action && this._retainedActions.indexOf(action) === -1) {
        this._retainedActions.push(action);
        action.retain();
    }
},

The array “retainedActions()” is never released until function “releaseAllActions()” is called. The only place it will be called is in the function “onPreDestroy()”;

_releaseAllActions: function () {
    if (CC_JSB) {
        for (var i = 0; i < this._retainedActions.length; ++i) {
            this._retainedActions[i].release();
        }
        this._retainedActions.length = 0;
    }
},

This behaviour will cause endless increment in the retainedActions array in scenarios where node will never be destroyed (eg: usage of node pool) and new action will also be ran on the node mentioned.

Can anyone from the Cocos team verify this issue or there is something I missed?