From: DongHyun Song Date: Thu, 29 Oct 2020 07:10:52 +0000 (+0900) Subject: [Service] Release fake timer when stopService. X-Git-Tag: accepted/tizen/unified/20201102.124300~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=719e2eed6fa5e882b6075d56f78c4e1a6330d378;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service] Release fake timer when stopService. 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 --- diff --git a/wrt_app/common/service_runner.ts b/wrt_app/common/service_runner.ts index c3c8306..a869101 100644 --- a/wrt_app/common/service_runner.ts +++ b/wrt_app/common/service_runner.ts @@ -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();