mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
beautify error info
This commit is contained in:
@@ -110,15 +110,15 @@ proto.getUuidArray = function (path, type, out_urls) {
|
||||
return uuids;
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en Returns all asset paths in the table.
|
||||
* !#zh 返回表中的所有资源路径。
|
||||
* @method getAllPaths
|
||||
* @return {string[]}
|
||||
*/
|
||||
proto.getAllPaths = function () {
|
||||
return Object.keys(this._pathToUuid);
|
||||
};
|
||||
// /**
|
||||
// * !#en Returns all asset paths in the table.
|
||||
// * !#zh 返回表中的所有资源路径。
|
||||
// * @method getAllPaths
|
||||
// * @return {string[]}
|
||||
// */
|
||||
// proto.getAllPaths = function () {
|
||||
// return Object.keys(this._pathToUuid);
|
||||
// };
|
||||
|
||||
/**
|
||||
* !#en TODO
|
||||
@@ -138,6 +138,26 @@ proto.add = function (path, uuid, type, isMainAsset) {
|
||||
pushToMap(this._pathToUuid, path, newEntry, isMainAsset);
|
||||
};
|
||||
|
||||
proto.getInfo_DEBUG = CC_DEBUG && function (uuid) {
|
||||
var path2uuid = this._pathToUuid;
|
||||
var paths = Object.keys(path2uuid);
|
||||
for (var p = 0; p < paths.length; ++p) {
|
||||
var path = paths[p];
|
||||
var item = path2uuid[path];
|
||||
if (Array.isArray(item)) {
|
||||
for (var i = 0; i < item.length; i++) {
|
||||
var entry = item[i];
|
||||
if (entry.uuid === uuid) {
|
||||
return { path: path, type: entry.type };
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.uuid === uuid) {
|
||||
return { path: path, type: item.type };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
proto.reset = function () {
|
||||
this._pathToUuid = {};
|
||||
};
|
||||
|
||||
@@ -42,17 +42,25 @@ ReleasedAssetChecker.prototype.setReleased = function (item, releasedKey) {
|
||||
};
|
||||
|
||||
function getItemDesc (item) {
|
||||
var desc = item.rawUrl;
|
||||
if (item.uuid) {
|
||||
desc += `(${item.uuid})`;
|
||||
var info = cc.loader._resources.getInfo_DEBUG(item.uuid);
|
||||
if (info) {
|
||||
info.path = 'resources/' + info.path;
|
||||
return `"${info.path}" (type: ${JS.getClassName(info.type)}, uuid: ${item.uuid})`;
|
||||
}
|
||||
else {
|
||||
return `"${item.rawUrl}" (${item.uuid})`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return `"${item.rawUrl}"`;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
function doCheckCouldRelease (releasedKey, refOwnerItem, caches) {
|
||||
var loadedAgain = caches[releasedKey];
|
||||
if (!loadedAgain) {
|
||||
cc.warn(`${releasedKey} was released but still referenced by ${getItemDesc(refOwnerItem)}`);
|
||||
cc.log(`"${releasedKey}" was released but maybe still referenced by ${getItemDesc(refOwnerItem)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,16 +73,16 @@ ReleasedAssetChecker.prototype.checkCouldRelease = function (caches) {
|
||||
|
||||
var released = this._releasedKeys;
|
||||
|
||||
// touch dependencies
|
||||
// check loader cache
|
||||
for (let id in caches) {
|
||||
var item = caches[id];
|
||||
if (item.alias) {
|
||||
item = item.alias;
|
||||
}
|
||||
var depends = item.dependKeys;
|
||||
let depends = item.dependKeys;
|
||||
if (depends) {
|
||||
for (let i = 0; i < depends.length; ++i) {
|
||||
var depend = depends[i];
|
||||
let depend = depends[i];
|
||||
if (released[depend]) {
|
||||
doCheckCouldRelease(depend, item, caches);
|
||||
delete released[depend];
|
||||
@@ -82,6 +90,17 @@ ReleasedAssetChecker.prototype.checkCouldRelease = function (caches) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // check current scene
|
||||
// let depends = cc.director.getScene().dependAssets;
|
||||
// for (let i = 0; i < depends.length; ++i) {
|
||||
// let depend = depends[i];
|
||||
// if (released[depend]) {
|
||||
// doCheckCouldRelease(depend, item, caches);
|
||||
// delete released[depend];
|
||||
// }
|
||||
// }
|
||||
|
||||
// clear released
|
||||
JS.clear(released);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user