From: liwei Date: Mon, 15 Mar 2021 05:58:07 +0000 (+0800) Subject: Minor refactor logic of quit for non-multitasking app X-Git-Tag: submit/tizen/20210317.160018~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F255197%2F3;p=platform%2Fframework%2Fweb%2Fwrtjs.git Minor refactor logic of quit for non-multitasking app 1.If app run in background and not support multitasking, app will quit immediatly, window will be desotried, then exception will happen, so ahead timing of addon event to avid window is null, ahead timing of addon event contentDidFinishLoad. 2.Set timeout to 0 for app.quit(), then it will be a little delay, it can avoid crash. Change-Id: I8c0cc11f13c48384e5a3e1965a1fc27353e81a3a Signed-off-by: liwei --- diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 6afc4acb..9d782c78 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -278,6 +278,7 @@ export class WebApplication { console.log('webContents did-finish-load'); this.loadFinished = true; wrt.hideSplashScreen(1); + addonManager.emit('contentDidFinishLoad', this.mainWindow.id); if (wrt.isIMEWebApp()) { this.activateIMEWebHelperClient(); } else if (wrt.tv) { @@ -286,7 +287,6 @@ export class WebApplication { else this.suspendByStatus(); } - addonManager.emit('contentDidFinishLoad', this.mainWindow.id); }); } @@ -411,13 +411,12 @@ Then you can get profile log from the initial loading.`; this.suspended = true; this.windowList[this.windowList.length - 1].hide(); this.flushData(); - if (!this.backgroundRunnable()) { - if (!this.multitaskingSupport) { + this.windowList.forEach((window) => window.setEnabled(false)); + if (!this.backgroundRunnable() && !this.multitaskingSupport) { + setTimeout(() => { console.log('multitasking is not supported; quitting app') app.quit(); - } else { - this.windowList.forEach((window) => window.setEnabled(false)); - } + }, 0); } }