[Service] Skip start service when app terminate & Check wrt-service launcher to 4s 19/274919/3
authorliwei <wei90727.li@samsung.com>
Thu, 12 May 2022 05:41:21 +0000 (13:41 +0800)
committerliwei <wei90727.li@samsung.com>
Thu, 12 May 2022 09:36:01 +0000 (17:36 +0800)
Now an issue happen, service app is launched for a little time, then
wrt-service-launcher is killed by unknown reason, then wrt-service
start to stop, guess xwalk-extension is not stopped completely, at the
same time, service app is reqeusting preview, then crash happen, so
do below changes.

1. Skip start service when app is terminating.
2. Check wrt-service-launcher from 2s to 4s.

Change-Id: I4a7c4b946a89d1a1f6a46903e3582a1d91248888
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/service/service_manager.ts
wrt_app/service/service_runner.ts

index c639eba3238ed692d0c59cc051fc96a8e572713f..de807eb8869d61776f91e88f9ff9446eb316c1eb 100644 (file)
@@ -24,6 +24,15 @@ function checkDyingWorker() {
   }
 }
 
+function IsDyingWorker(id: string) {
+  let dyingWorkers = Object.keys(dyingWorkerQueue);
+  if (dyingWorkers.length && dyingWorkerQueue[id]) {
+    return ((dyingWorkerQueue[id] === 'will-terminate') ||
+            (dyingWorkerQueue[id] === 'terminated'))
+  }
+  return false;
+}
+
 function createWorker(id: string, startService: string, filename: string) {
   if (workers[id]) {
     workers[id].postMessage({ type: 'wake' });
@@ -73,6 +82,10 @@ let initializeExtensionOnMain = () => {
 }
 
 export function startService(id: string, filename: string) {
+  if(IsDyingWorker(id)) {
+    console.debug(`startService - ${id} is in stop status, skip start`);
+    return;
+  }
   console.debug(`startService - ${id}`);
   initializeExtensionOnMain();
   if (global['serviceType'] === 'STANDALONE') {
index 405c9e96e68e8fd4c53e1bf05ce7dc39d778e88b..5a1b65cd60b3a83d3491199620c2ded0a3143792 100644 (file)
@@ -49,12 +49,12 @@ let requestStopService = (id: string) => {
 
 let app: any = null;
 let dummyTimer: any;
-let periodLauncherAlive = 20; // 2s
+let periodLauncherAlive = 40; // 4s
 
 let checkLauncherAlive = (id: string) => {
   periodLauncherAlive--;
   if (!periodLauncherAlive) {
-    periodLauncherAlive = 20;
+    periodLauncherAlive = 40;
     if (!wrt.checkLauncherAlive(id)) {
       console.debug(`${id} launcher was killed.`)
       requestStopService(id);