creator1.4.2版本中添加节点打包安卓后出现卡顿,web版本没事。

cc.Class({
extends: cc.Component,

properties: {
    // foo: {
    //    default: null,      // The default value will be used only when the component attaching
    //                           to a node for the first time
    //    url: cc.Texture2D,  // optional, default is typeof default
    //    serializable: true, // optional, default is true<a class="attachment" href="/uploads/default/original/3X/f/9/f98d7965b80cf8038f74da1238aaa365bff161c6.zip">NewProject.zip</a> (267.7 KB)
    //    visible: true,      // optional, default is true
    //    displayName: 'Foo', // optional
    //    readonly: false,    // optional, default is false
    // },
    // ...
    
    Fish: {
        default: null,
        type: cc.Prefab
    },
    
    times: 0,
},

// use this for initialization
onLoad: function () {
    this.init();
},

init: function() {
    this.birdArray=[];
    let FishNum=200;
    var Fish = null;
    this.FishPool = new cc.NodePool("bird");
    for(var i = 0; i < FishNum; ++i){
        Fish = cc.instantiate(this.Fish); // 创建节点
        this.FishPool.put(Fish); // 通过 putInPool 接口放入对象池
    }
},

createBird: function(){
    var Fish=null;
    if(this.FishPool.size()>0){
        Fish=this.FishPool.get();
    }else{
        return;
    }
    Fish.parent=this.node;
    Fish.setPosition(cc.p(700,0));
    var moveAction = cc.moveTo(10,cc.p(-700,0));
    var sequenceAction = cc.sequence(moveAction,cc.callFunc(function(){
        this.FishPool.put(Fish);
    },this));
    Fish.runAction(sequenceAction);
    Fish.getComponent("cc.Animation").play("0");
},


// called every frame, uncomment this function to activate update callback
update: function (dt) {
    if (this.times % 6 === 0)
        this.createBird();
    this.node.getChildByName("Label").getComponent("cc.Label").string=this.times;
    this.times++;
},

});
上面不断生成了prefab中的动画,但每当添加节点超过2000到3000个时,就会出现卡顿,配置越低的手机,卡的时间越长,有人遇到过吗??NewProject.zip (267.7 KB)

1.6会对性能有大幅优化。如果要稍稍改善,试试1.5,但还是会越来越慢的。

应该是,有2000个动画同时在场,就会卡死1秒以上,而不是掉帧。在13秒左右

如果只有100个动画同时在场,也会卡死,只是出现的时间会长一些。

Fish.getComponent(“cc.Animation”).play(“0”);

在runtime-win32 就能测试出来了。

动画越多,卡死的时间越平凡。

望官方正视,刚刚拿这个程序做了一个测试。
测试1:
放1000个动画同时在场,不清除,9秒卡顿,
测试2:
100个动画同时在场,不清除,90秒卡顿
测试3:
10个动画在场,不清除,900秒基本误差非常小。

神奇,

预估只有一个动画,没有其他任何多余的精灵,9000秒会卡顿。

程序简化:这样就可以测试出
properties: {

    Fish: {
        default: null,
        type: cc.Prefab
    },
    
    times: 0,
},

// use this for initialization
onLoad: function () {
    this.init();
},

init: function() {
    cc.director.setDisplayStats( true );
    var FishNum=1000;
    var Fish = null;
    for(var i = 0; i < FishNum; ++i){
        Fish = cc.instantiate(this.Fish); // 创建节点
        this.node.addChild(Fish);
        Fish.setPosition(cc.p(100,100));
        Fish.getComponent("cc.Animation").play("0");
    }
},


update: function (dt) {
    this.node.getChildByName("Label").getComponent("cc.Label").string=this.times;
    this.times++;
},

1.5.0版本一样的卡顿

龙骨不卡,可尝试

@panda 不帮看看这个问题吗?

这个问题意味着,在native环境下,任何一个animation持续播放长时间就会出现卡顿,animation越多出现就越平凡,

10个animation 都会出现卡顿,属于正常吗?

没管理帮看看吗?

不只是动画,prefab的创建在,android下卡顿严重,望官方重视!

就放一个动画来回移动,也会出现卡的现象,web上确实好的,手机和模拟器上都出现卡

1赞

安卓的卡顿问题会在 1.6 解决,目前已经成功升级了 Spidermonkey 到 v52 版本,验证了 JS 性能的提升,GC 损耗的下降,有需要测试的用户可以联系我

1赞

需要测试

加我 QQ 100362595

@panda 我用1.6meta打的原生包 依旧会出现卡顿问题 原本1.4是9秒卡一次 现在30几秒卡一次 但始终还是会卡 很影响游戏体验 有什么办法能解决或者避免吗?

尽量减少对象重复创建,缓存临时对象,启用对象池之类的。可以在 web 浏览器上先把这一块内容调试好。

关键是H5完全不会啊。。只有打包到安卓才会。。而且我做的是捕鱼游戏,必须要大量创建,也用了对象池了,但还是一样哦

你胆子真大~~ 敢用ccc做捕鱼 哈哈哈

一般托管语言都会有 GC 时的卡顿问题,Unity 也不例外,没有办法完美避免。