From: zhaosy Date: Fri, 25 Oct 2024 05:26:36 +0000 (+0800) Subject: [VD] Don't show app if preload app is not ready X-Git-Tag: submit/tizen/20241029.160027^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90212b27f78af494ef37e237632b0fb0ac317ba4;p=platform%2Fframework%2Fweb%2Fwrtjs.git [VD] Don't show app if preload app is not ready For ConnectTime app, when there is a video calling coming, they will preload app, and when user connect the call, they launch app, if the interval too short between perload and launch, js still is not running when app is showing, but WRT has sent tizenvisibilitychange. So app can't receive tizenvisibilitychange event. Thus, if preload app is not ready, shouldn't show app. Change-Id: I3838a1acf9e7f59d4d339e92c4417d13b1c6e363 Signed-off-by: zhaosy --- diff --git a/wrt_app/common/web_application_delegate.ts b/wrt_app/common/web_application_delegate.ts index a51da49b..1ac4626d 100644 --- a/wrt_app/common/web_application_delegate.ts +++ b/wrt_app/common/web_application_delegate.ts @@ -46,4 +46,5 @@ export class WebApplicationDelegate { profileName() { return 'common' } certificateError(error: string) { return false; } setInitValue(appControl: any) { } + preloadReady() { return true; } } diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index c28497c4..e1f0d0aa 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -27,6 +27,7 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate { isAlwaysReload: boolean = false; initBundleValue: string = 'none'; preloadStatus: string = 'none'; + isPreloadReady: boolean = true; runningStatus: string = 'none'; launchMode: string = 'none'; needDispatchTizenVisibilityChange: boolean = false; @@ -41,6 +42,7 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate { console.log(`launch mode is ${this.launchMode}`); if (options.launchMode === 'backgroundAtStartup') { this.preloadStatus = 'preload'; + this.isPreloadReady = false; } else { this.preloadStatus = 'none'; } @@ -218,7 +220,7 @@ Then you can get profile log from the initial loading.`; this.webApplication.sendAppControlEvent(); return false; } else if ((this.launchMode === 'runningAsForeground') || (resumeWithAppControl === 'Yes')) { - this.webApplication.resume(); + this.webApplication.show(); this.webApplication.sendAppControlEvent(); return false; } else { @@ -281,4 +283,15 @@ Then you can get profile log from the initial loading.`; focus(webContents: any) { this.tv.focus(webContents); } + + preloadReady() { + if (this.isPreloadReady) + return true; + + if (!this.webApplication.readyToShow) + return false; + + this.isPreloadReady = true; + return true; + } } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index ec44056e..e853e581 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -45,6 +45,7 @@ export class WebApplication { splashShown: boolean = false; reload: boolean = false; earlyLoadedUrl: string = ''; + readyToShow: boolean = false; constructor(options: RuntimeOption) { if (wrt.tv) { @@ -230,6 +231,7 @@ export class WebApplication { return; console.log('mainWindow ready-to-show'); + this.readyToShow = true; if (this.showTimer) clearTimeout(this.showTimer); @@ -431,6 +433,11 @@ export class WebApplication { } show() { + if (!this.profileDelegate.preloadReady()) { + console.log('preload is not ready'); + return; + } + if (this.profileDelegate.isBackgroundLaunch()) { console.log('show() will be skipped by background launch'); return;