Refactor suspend sequence 55/246155/5
authorDongHyun Song <dh81.song@samsung.com>
Mon, 26 Oct 2020 10:07:57 +0000 (19:07 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Mon, 26 Oct 2020 10:53:53 +0000 (10:53 +0000)
To guarantee unload* events, suspend() should be deffered after
closing windows.

Related patch:
  https://review.tizen.org/gerrit/246015/
  https://review.tizen.org/gerrit/245417/

Change-Id: Id13a275b64e75f985e0115eee6771e3c29dd9cd9
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/src/web_application.ts

index 3795a2a..5a57298 100644 (file)
@@ -345,14 +345,14 @@ Then you can get profile log from the initial loading.`;
   }
 
   suspend() {
-    if (this.suspended)
+    if (this.suspended || this.inQuit)
       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() || this.inQuit) {
+    if (!this.backgroundRunnable()) {
       if (!this.multitaskingSupport) {
         // FIXME : terminate app after visibilitychange event handling
         setTimeout(() => {
@@ -383,6 +383,9 @@ Then you can get profile log from the initial loading.`;
     console.log('WebApplication : finalize');
     this.flushData();
     this.windowList.forEach((window) => window.removeAllListeners());
+    this.inQuit = false;
+    if (!this.suspended)
+      this.suspend();
   }
 
   quit() {
@@ -398,8 +401,6 @@ Then you can get profile log from the initial loading.`;
       wrt.stopInspectorServer();
     }
     this.inQuit = true;
-    if (!this.suspended)
-      this.suspend();
   }
 
   private flushData() {