From: DongHyun Song Date: Thu, 22 Oct 2020 05:15:08 +0000 (+0900) Subject: Refactor suspend sequence X-Git-Tag: accepted/tizen/unified/20201029.124952~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F246015%2F5;p=platform%2Fframework%2Fweb%2Fwrtjs.git Refactor suspend sequence 1) Bring forward suspend time when before-quit. ** When OnTerminate is coming first earlier than OnPause, 'quit' makes this.webApplication as undefined, then wrt.on('suspend'...) will be skipped. This means that With normal termination sequence, suspending might be not handled. 2) Even though background runnable app, when app is in quitting, enable suspend sequence for right termination sequence. Change-Id: Ie40f650ea317d6f198f9c1c1aa07c9bc6867b693 Signed-off-by: DongHyun Song --- diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 61bbfd7..3e5a683 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -44,6 +44,7 @@ export class WebApplication { runningStatus = 'none'; suspended = false; windowList: Electron.BrowserWindow[] = []; + inQuit = false; constructor(options: RuntimeOption) { if (options.launchMode == 'backgroundAtStartup') { @@ -344,12 +345,14 @@ Then you can get profile log from the initial loading.`; } suspend() { + if (this.suspended) + return; console.log('WebApplication : suspend'); addonManager.emit('lcSuspend', this.mainWindow.id); this.suspended = true; this.windowList[this.windowList.length - 1].hide(); this.flushData(); - if (!this.backgroundRunnable()) { + if (!this.backgroundRunnable() || this.inQuit) { if (!this.multitaskingSupport) { // FIXME : terminate app after visibilitychange event handling setTimeout(() => { @@ -394,6 +397,9 @@ Then you can get profile log from the initial loading.`; quit() { console.log('WebApplication : quit'); addonManager.emit('lcQuit', this.mainWindow.id); + this.inQuit = true; + if (!this.suspended) + this.suspend(); } private flushData() {