From ba115a874e610dc86953a45ef7da2b0627412e46 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 22 Oct 2020 14:15:08 +0900 Subject: [PATCH] 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 --- wrt_app/src/web_application.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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() { -- 2.7.4