mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-25 11:18:30 +00:00
[adapters] 降低 Worker 初始化对启动速度的影响,增加宏设置打印
This commit is contained in:
parent
9df0cdee8f
commit
cf7307d7f5
@ -1,5 +1,6 @@
|
||||
const initWorker = require('./worker_adapter/index.js');
|
||||
const { init: initWorker, onInited: onWorkerInited } = require('./worker_adapter/index.js');
|
||||
require('adapter-js-path');
|
||||
initWorker();
|
||||
__globalAdapter.init();
|
||||
require('cocos2d-js-path');
|
||||
require('physics-js-path');
|
||||
@ -18,6 +19,8 @@ if (cc.sys.platform !== cc.sys.WECHAT_GAME_SUB) {
|
||||
cc.macro.CLEANUP_IMAGE_CACHE = true;
|
||||
}
|
||||
|
||||
initWorker(() => {
|
||||
const t = Date.now();
|
||||
onWorkerInited(() => {
|
||||
console.log("worker waiting time:", Date.now() - t);
|
||||
window.boot();
|
||||
});
|
||||
|
@ -2,14 +2,38 @@ require("./macro.js");
|
||||
require("./ipc-main.js");
|
||||
require("./handlers.js");
|
||||
|
||||
module.exports = function init(callback) {
|
||||
if (CC_USE_WORKER) {
|
||||
var t = Date.now();
|
||||
ipcMain.init(() => {
|
||||
console.log("worker init cost:", Date.now() - t);
|
||||
let inited = false;
|
||||
let _callback = null;
|
||||
|
||||
module.exports = {
|
||||
init() {
|
||||
if (CC_USE_WORKER) {
|
||||
var t = Date.now();
|
||||
ipcMain.init(() => {
|
||||
console.log("worker init cost:", Date.now() - t);
|
||||
console.log("worker settings:", {
|
||||
CC_USE_WORKER,
|
||||
CC_WORKER_DEBUG,
|
||||
CC_WORKER_ASSET_PIPELINE,
|
||||
CC_WORKER_ASSET_PIPELINE_INCLUDE_LOAD,
|
||||
CC_WORKER_SCHEDULER,
|
||||
CC_WORKER_FS_SYNC,
|
||||
});
|
||||
inited = true;
|
||||
_callback && _callback();
|
||||
_callback = null;
|
||||
});
|
||||
} else {
|
||||
inited = true;
|
||||
_callback && _callback();
|
||||
_callback = null;
|
||||
}
|
||||
},
|
||||
onInited(callback) {
|
||||
if (inited) {
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_callback = callback;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user