Commit bcfbf337 authored by limingzhe's avatar limingzhe

fix: debug 内存溢出

parent de075337
......@@ -398,6 +398,7 @@ export default class NewClass extends middleLayerBase {
// 重写loadOnlineBundle方法;主要是对一些必要的页面跳转做一些拦截处理
loadOnlineBundle(bundleName, callback = null) {
console.log(" in loadOnlineBundle")
cc.find('middleLayer/BtnRight').active = false;
cc.find('middleLayer/BtnLeft').active = false;
cc.find('middleLayer/ExitBtn').active = false;
......@@ -617,11 +618,17 @@ export default class NewClass extends middleLayerBase {
const syllabusPath = this.getData("syllabus_path");
console.log("[middleLayer_for_NJ_lite] onClickExitBtn syllabusPath=", JSON.stringify(syllabusPath))
if (!syllabusPath) {
console.log('xxxx 1')
this.loadOnlineBundle('NJ_YouLeChang');
return;
}
if (syllabusPath.type==="pdtd"){
console.log('xxxx 2')
if (syllabusPath.pdtd_type == 'game_select') {
console.log('xxxx 3')
this.setData("NJ_game_select", {
step: 0,
currentPartIdx: 0
......@@ -635,16 +642,25 @@ export default class NewClass extends middleLayerBase {
this.loadOnlineBundle('NJ_NongChang');
}
} else {
console.log('xxxx 4')
this.loadOnlineBundle('NJ_MoreGames_CourseList');
}
} else if (syllabusPath.type === "ydjyz") {
console.log('xxxx 5')
if (this.courseItem.template_name == "NJ_BookTable") {
console.log('xxxx 6')
this.loadOnlineBundle('NJ_YueDuJiaYouZhan');
} else {
const bookTable = this.getData("NJ_BookTable");
this.loadOnlineCourseWare(bookTable.courseId);
}
} else if (syllabusPath.type === "qwqd") {
console.log('xxxx 8')
this.loadOnlineBundle('NJ_MonkyTree');
}
}
......
......@@ -123,6 +123,7 @@ export abstract class middleLayerBase extends cc.Component {
}
loadOnlineBundle(bundleName, callback = null) {
console.log(' in loadOnlineBundle')
cc.find('middleLayer/BtnRight').active = false;
cc.find('middleLayer/BtnLeft').active = false;
cc.find('middleLayer/ExitBtn').active = false;
......@@ -172,6 +173,7 @@ export abstract class middleLayerBase extends cc.Component {
}
reloadBundle() {
console.log(' in reloadBundle');
const { sceneName, version, bondleUrl } = this.currentBundleInfo;
this.loadBundle(sceneName, version, bondleUrl);
}
......@@ -184,6 +186,7 @@ export abstract class middleLayerBase extends cc.Component {
this.assetList = [];
this.textureList = [];
this.assetObj = {};
this.atlasList = [];
this.nodeList = [];
console.log('汪汪汪: getDragonDisplayAssetList');
......@@ -193,19 +196,19 @@ export abstract class middleLayerBase extends cc.Component {
console.log('喵喵喵3: ' + this.assetList.length);
console.log('喵喵喵4: ' + this.textureList.length);
// this.clearDragonDisplayAssetList2();
this.loadBundleLock = true; // 加锁
this.currentBundleInfo = { sceneName, version, bondleUrl };
console.log("[middleLayer_for_NJ_lite]-[loadBundle] currentBundleInfo=", JSON.stringify(this.currentBundleInfo))
this.showWaitingLetters();
cc.audioEngine.stopAll();
const oldSceneName = this.currentBundleInfo?.sceneName;
const engineInfo = await this.getEngineInfo();
const { isChanged } = JSON.parse(engineInfo);
if (isChanged) {
await this.checkRotateScreen(oldSceneName, sceneName);
}
// const oldSceneName = this.currentBundleInfo?.sceneName;
// const engineInfo = await this.getEngineInfo();
// const { isChanged } = JSON.parse(engineInfo);
// if (isChanged) {
// await this.checkRotateScreen(oldSceneName, sceneName);
// }
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
bundle.loadScene(sceneName, null, null, (err, scene) => {
......@@ -230,10 +233,11 @@ export abstract class middleLayerBase extends cc.Component {
const destroyer = cc.instantiate(cc.find('middleLayer/Destroyer'));
if (destroyer) {
// if (destroyer) {
destroyer.parent = cc.find('Canvas');
destroyer.active = true;
}
// }
callback && callback();
......@@ -328,6 +332,7 @@ export abstract class middleLayerBase extends cc.Component {
}
loadPageBundle(callback = null) {
console.log(" in loadPageBundle");
let sceneName, version, bondleUrl = "";
const templateBaseUrl = `${this.DOMAIN}h5template/${this.courseItem.template_name}/v${this.courseItem.last_version}`;
this.getConfigInfo(templateBaseUrl, (conf) => {
......@@ -412,13 +417,75 @@ export abstract class middleLayerBase extends cc.Component {
clearDragonDisplayAssetList() {
console.log('喵喵喵: clearDragonDisplayAssetList');
console.log('喵喵喵: ' + this.nodeList.length);
console.log('喵喵喵: ' + this.atlasList.length);
console.log('喵喵喵: ' + this.assetList.length);
console.log('喵喵喵: ' + this.textureList.length);
[...this.atlasList, ...this.assetList].forEach(asset => {
if (this.atlasList.length == 0) {
return;
}
// this.atlasList[3] = this.atlasList[7];
// this.assetList[3] = this.assetList[7];
// this.nodeList[3] = this.nodeList[7];
// this.textureList[3] = this.textureList[7];
// this.atlasList.length = this.assetList.length = this.nodeList.length = this.textureList.length = 1;
[ ...this.atlasList, ...this.assetList ].forEach(asset => {
console.log('asset_uuid: ', asset._uuid);
console.log('asset: ', asset);
while (asset?.refCount > 0) {
asset.decRef();
}
// cc.assetManager.releaseAsset(asset);
// asset.destroy();
});
this.nodeList.forEach(node => {
node.active = false;
node.removeFromParent();
});
this.textureList.forEach(texture => {
console.log('texture_uuid: ', texture._uuid);
console.log('texture: ', texture);
while (texture?.refCount > 0) {
texture.decRef();
}
});
this.atlasList.length = this.assetList.length = this.nodeList.length = this.textureList.length = 1;
[ ...this.atlasList, ...this.assetList ].forEach(asset => {
console.log('asset_uuid: ', asset._uuid);
console.log('asset: ', asset);
// asset.decRef();
cc.assetManager.releaseAsset(asset);
// asset.destroy();
});
}
clearDragonDisplayAssetList2() {
console.log('喵喵喵: clearDragonDisplayAssetList');
console.log('喵喵喵: ' + this.nodeList.length);
console.log('喵喵喵: ' + this.atlasList.length);
console.log('喵喵喵: ' + this.assetList.length);
console.log('喵喵喵: ' + this.textureList.length);
[ ...this.atlasList , ...this.assetList].forEach(asset => {
asset.decRef();
cc.assetManager.releaseAsset(asset);
asset.destroy();
......@@ -432,8 +499,10 @@ export abstract class middleLayerBase extends cc.Component {
this.textureList.forEach(texture => {
texture.decRef();
});
}
assetObj = null;
nodeList = null;
atlasList = null;
assetList = null;
......@@ -452,11 +521,19 @@ export abstract class middleLayerBase extends cc.Component {
return;
}
// const uuid = asset._uuid;
// if (!this.assetObj[uuid]) {
this.nodeList.push(node);
this.atlasList.push(atlas);
this.assetList.push(asset);
this.textureList.push(atlas.texture);
// this.assetObj[uuid] = true;
console.log('汪汪汪: atlas.texture.nativeUrl = ' + atlas.texture.nativeUrl);
// }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment