[Service] Check launcher process 93/254893/5 accepted/tizen/unified/20210319.140915 submit/tizen/20210317.160018 submit/tizen/20210318.093709
authorDongHyun Song <dh81.song@samsung.com>
Wed, 10 Mar 2021 09:09:59 +0000 (18:09 +0900)
committerSangYong Park <sy302.park@samsung.com>
Wed, 17 Mar 2021 05:02:19 +0000 (05:02 +0000)
Check launcher process if it is alive, otherwise stop the service.

Related chromium-efl patch:
  https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/247802/

Change-Id: Iac686bcf5ecc5acaec69599f11571a00f137de22
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/common/service_runner.ts

index f372d96..4c62afb 100644 (file)
@@ -51,7 +51,20 @@ let requestStopService = (id: string) => {
 }
 
 let app: any = null;
-let fakeTimer: any;
+let dummyTimer: any;
+let periodLauncherAlive = 20; // 2s
+
+let checkLauncherAlive = (id: string) => {
+  periodLauncherAlive--;
+  if (!periodLauncherAlive) {
+    periodLauncherAlive = 20;
+    if (!wrt.checkLauncherAlive(id)) {
+      console.log(`${id} launcher was killed.`)
+      requestStopService(id);
+      checkLauncherAlive = () => {};
+    }
+  }
+}
 
 export function start(id: string, filename: string) {
   XWalkExtension.initialize();
@@ -71,9 +84,10 @@ export function start(id: string, filename: string) {
     console.log(`start global service file: ${filename}`);
   }
 
-  // FIXME: this is for awaking up uv loop.
-  // uv loop is sleeping for a few second with tizen webapis's aync callback
-  fakeTimer = setInterval(() => {}, 100);
+  // This is for awaking up uv loop.
+  dummyTimer = setInterval(() => {
+    checkLauncherAlive(id);
+  }, 100);
   printAppControlData(id);
 
   try {
@@ -99,8 +113,8 @@ export function start(id: string, filename: string) {
 }
 
 export function stop(id: string) {
-  if (fakeTimer)
-    clearInterval(fakeTimer);
+  if (dummyTimer)
+    clearInterval(dummyTimer);
   try {
     if (app.onStop !== undefined) {
       app.onStop();