Stop Inspector when all windows are closed 04/280604/3 submit/tizen/20220923.160021
authorliwei <wei90727.li@samsung.com>
Thu, 1 Sep 2022 05:36:43 +0000 (13:36 +0800)
committerliwei <wei90727.li@samsung.com>
Thu, 22 Sep 2022 11:04:07 +0000 (19:04 +0800)
Some apps(ex. hulu) will call window.close() when terminate, it will cause
'before-quit' invoked after 'window-all-closed'. In current logic, WRT stop
inspector when receive 'before-quit' event, but at this case, any wrt api
cannot be called successfully(I think it's related with window is closed firstly),
so stop inspector in 'window-all-closed' event, then RWI cannot stopped properly and
RWI port will be released normally

Change-Id: I8d3d46973cc1536bf6818c346d7c3ef43ed4be0a
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/src/runtime.ts
wrt_app/src/web_application.ts

index 6bc933a..c1a2e8e 100644 (file)
@@ -49,6 +49,7 @@ class Runtime {
 
     app.on('window-all-closed', () => {
       console.log('window-all-closed');
+      this.webApplication?.stopInspector();
       app.quit();
     });
 
index c7d497a..eef640b 100644 (file)
@@ -302,6 +302,14 @@ export class WebApplication {
     }
   }
 
+  stopInspector() {
+    if (this.debugPort) {
+      console.log('stop inspector server');
+      this.debugPort = 0;
+      wrt.stopInspectorServer();
+    }
+  }
+
   loadUrl(appControl: NativeWRTjs.AppControl) {
     this.contentSrc = appControl.getLoadInfo().getSrc();
     this.launchInspectorIfNeeded(appControl);
@@ -361,11 +369,7 @@ export class WebApplication {
     console.log('WebApplication : beforeQuit');
     this.profileDelegate.beforeQuit();
     addonManager.emit('lcQuit', this.mainWindow.id);
-    if (this.debugPort) {
-      console.log('stop inspector server');
-      this.debugPort = 0;
-      wrt.stopInspectorServer();
-    }
+    this.stopInspector();
     this.inQuit = true;
   }