[Tizen 8.0 Migration][Service] Fix exception and change dummyTimer's interval 47/294247/1 submit/tizen/20230615.160023
authorDongHyun Song <dh81.song@samsung.com>
Fri, 19 May 2023 05:00:55 +0000 (14:00 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Thu, 15 Jun 2023 03:57:42 +0000 (03:57 +0000)
1)
When the app has resumed If the service app has no onRequest function,
JS exception can be raised. So, undefined check is necessary.

2)
Because UvTaskRunner has 500ms interval, 100ms timer is not meaningful
in Node application.

Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/293070/

Change-Id: Id94e561e1c1e1c516c8c9ba82d664f83e2d6f404
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
(cherry picked from commit 4ff972858c6fef14074e2d6ae797ee56a7ad8536)

wrt_app/service/service_runner.ts

index 355347c..ef210c2 100644 (file)
@@ -53,13 +53,13 @@ let requestStopService = (id: string) => {
 
 let app: any = null;
 let dummyTimer: any;
-let periodLauncherAlive = 40; // 4s
+let periodLauncherAlive = 8; // 4s, 500ms dummy timer checks the launcher aliveness every 8 times.
 let deviceApiRouter: any = null;
 
 let checkLauncherAlive = (id: string) => {
   periodLauncherAlive--;
   if (!periodLauncherAlive) {
-    periodLauncherAlive = 40;
+    periodLauncherAlive = 8;
     if (!wrt.checkLauncherAlive(id)) {
       console.debug(`${id} launcher was killed.`)
       requestStopService(id);
@@ -99,7 +99,7 @@ export function start(id: string, filename: string) {
   if (isGlobalService()) {
     dummyTimer = setInterval(() => {
       checkLauncherAlive(id);
-    }, 100);
+    }, 500);
   }
 
   if (isServiceApplication()) {
@@ -162,7 +162,7 @@ function run() {
     console.debug(`Received message type : ${message.type}`);
     switch (message.type) {
       case 'wake':
-        app?.onRequest();
+        app?.onRequest?.();
         break;
       case 'stop':
         stop(id);