Don't show app if preload app is not ready 34/315634/1
authorzhaosy <shiyusy.zhao@samsung.com>
Wed, 4 Dec 2024 01:34:52 +0000 (09:34 +0800)
committerzhaosy <shiyusy.zhao@samsung.com>
Wed, 4 Dec 2024 01:34:52 +0000 (09:34 +0800)
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.

Refer to:
https://archive.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/319530/

Change-Id: I260a3d0339b92de49f2753d7c103f93df6aaf7f2
Signed-off-by: zhaosy <shiyusy.zhao@samsung.com>
wrt_app/common/web_application_delegate.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index a51da49b4d5788bd7b9a550d2c2f235db9ed5782..1ac4626d247b43c389afbbf526fc3704084840b2 100644 (file)
@@ -46,4 +46,5 @@ export class WebApplicationDelegate {
   profileName() { return 'common' }
   certificateError(error: string) { return false; }
   setInitValue(appControl: any) { }
+  preloadReady() { return true; }
 }
index c28497c4774a556e75999cb72c27141c80cd8f1c..e1f0d0aa1227353593bf6de2882d6beb1074c531 100644 (file)
@@ -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;
+  }
 }
index 6d35a7a2d0bd57eb1d4880db3b4894dd33539f7e..e853e581fc3096c6dfaef823bbc4fb59a70cfbee 100644 (file)
@@ -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);
 
@@ -412,6 +414,7 @@ export class WebApplication {
   }
 
   sendAppControlEvent() {
+    console.log('webApplication : sendAppControlEvent');
     const kAppControlEventScript = `(function(){
   var __event = document.createEvent("CustomEvent");
   __event.initCustomEvent("appcontrol", true, true, null);
@@ -430,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;