[Service] Release fake timer when stopService. 25/246425/3
authorDongHyun Song <dh81.song@samsung.com>
Thu, 29 Oct 2020 07:10:52 +0000 (16:10 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Thu, 29 Oct 2020 07:39:55 +0000 (16:39 +0900)
This fake timer is to avoid unknown uv loop delay issue.
It should clear this fake timer after stopService.

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

index c3c8306..a869101 100644 (file)
@@ -39,6 +39,8 @@ function requestStopService(id: string) {
 }
 
 let app: any = null;
+let fakeTimer: any;
+
 export function start(id: string, filename: string) {
   XWalkExtension.initialize();
   XWalkExtension.setRuntimeMessageHandler((type, data) => {
@@ -59,7 +61,7 @@ export function start(id: string, filename: string) {
 
   // FIXME: this is for awaking up uv loop.
   // uv loop is sleeping for a few second with tizen webapis's aync callback
-  setInterval(() => {}, 100);
+  fakeTimer = setInterval(() => {}, 100);
   try {
     app = require(filename);
     if (app.onStart !== undefined) {
@@ -78,6 +80,8 @@ export function start(id: string, filename: string) {
 }
 
 export function stop(id: string) {
+  if (fakeTimer)
+    clearInterval(fakeTimer);
   try {
     if (app.onStop !== undefined) {
       app.onStop();