Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

Cc.loader.loadRes调用多次会卡死

$
0
0

@ypengju1 写道:

let filename = "bg/background_4"
let startTime = new Date().getTime()
for (var j = 0; j < 1000; j++) {
    cc.loader.loadRes(filename, cc.SpriteFrame, function (err, frame) {
        if (err) {
            cc.log(err.message || err);
            return;
        }
    });
}
let endTime = new Date().getTime()
cc.log("===eventTime", endTime - startTime)

每次调用上边代码,耗时会越来越长,跟踪了下代码,发现是在LoadingItems中的下边这个方法

LoadingItems.finishDep = function (depId) {
    for (var id in _queueDeps) {
        var queue = _queueDeps[id];
        // Found root queue
        if (queue.deps.indexOf(depId) !== -1 && queue.completed.indexOf(depId) === -1) {
            queue.completed.push(depId);
        }
    }
};

_queueDeps会越来越大,for循环耗时越来越久

帖子: 3

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>