[VideoSplash] Fix focus issue of VSS and refactors 87/259987/10
authorDongHyun Song <dh81.song@samsung.com>
Fri, 25 Jun 2021 05:38:55 +0000 (14:38 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 25 Jun 2021 06:33:38 +0000 (15:33 +0900)
[PROBLEM] Before the update to VSS's player, the WRT.js could
          call WRT.hideSplashScreen(...), with one window show
          (after 'ready-to-show').

          With VSS player reacting to focus steal, now showing
          the window will result in premature playback stop.

[SOLUTION] With change in WRT interface in libchromium the
           WebApplication can now check, if the reason for
           hiding was valid.

           Side effect is, if the RENDERED was not a valid reason
           to hide a window, the window is not shown at any other
           event. The additional show() is therefore added to
           LOADFINISHED and CUSTOM (VIDEOFINISHED and CUSTOM's
           show() is already in the Chromium patch).

NOTE: part of this change was provided in Chromium project as change
[259340][1]. To have current change compile, you either have to have
chromium RPM with its change, or -- after first unsuccessfull build --
go to your GBS scratch area, into /usr/include/wrt/ and edit the
native_wrtjs.d.ts to have WRT.hideSplashScreen method return `boolean`.

[1]: https://review.tizen.org/gerrit/c/259340

Change-Id: Id63f6b4192cdc9da8da1e4ff0296f11bc15b10b3
Bug-Id: https://cam.sprc.samsung.pl/browse/WPMEDMAIN-2915
Signed-off-by: Marcin Zdun <m.zdun@samsung.com>
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/common/web_application_delegate.ts
wrt_app/src/runtime.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index b31a4d9..8d80b78 100644 (file)
@@ -44,5 +44,4 @@ export class WebApplicationDelegate {
   needShowTimer() { return true; }
   onDidFinishLoad() { }
   profileName() { return 'common' }
-  show() { }
 }
index 3a1d846..2f8a850 100644 (file)
@@ -109,6 +109,8 @@ class Runtime {
       } else if (type === 'stopService') {
         require('../common/service_manager').stopService(app_id);
         event.preventDefault();
+      } else if (type === 'hideSplashScreen') {
+        this.webApplication?.hideSplashScreen(params[0]);
       }
     });
 
index bbda5e2..ade4147 100644 (file)
@@ -116,12 +116,8 @@ Then you can get profile log from the initial loading.`;
   }
 
   private handlePreloadState(launchMode: string) {
-    if (this.preloadStatus === 'preload') {
-      this.show();
-    } else {
-      if (launchMode != 'backgroundAtStartup')
-        this.preloadStatus = 'none';
-    }
+    if (this.preloadStatus === 'preload' || launchMode != 'backgroundAtStartup')
+      this.preloadStatus = 'none';
   }
 
   backgroundExecutable() {
@@ -136,10 +132,6 @@ Then you can get profile log from the initial loading.`;
     return false;
   }
 
-  show() {
-    this.preloadStatus = 'none';
-  }
-
   canIgnoreSuspend() {
     if (this.launchMode == 'runningAsForeground' ||
         this.launchMode == 'runningAsBackground') {
index 8a39aaa..4d4872a 100644 (file)
@@ -42,6 +42,7 @@ export class WebApplication {
   windowList: Electron.BrowserWindow[] = [];
   inQuit: boolean = false;
   profileDelegate: WebApplicationDelegate;
+  splashShown: boolean = false;
 
   constructor(options: RuntimeOption) {
     if (wrt.tv) {
@@ -177,15 +178,42 @@ export class WebApplication {
     };
   }
 
+  hideSplashScreen(reason: string) {
+    switch (reason) {
+      case 'first-paint': {
+        if (wrt.hideSplashScreen(0) !== false)
+          this.show();
+        break;
+      }
+      case 'complete': {
+        if (wrt.hideSplashScreen(1) !== false)
+          this.show();
+        break;
+      }
+      case 'custom': {
+        if (wrt.hideSplashScreen(2) !== false)
+          this.show();
+        break;
+      }
+      case 'video-finished': {
+        this.show();
+        break;
+      }
+      default:
+        break;
+    }
+  }
+
   private setupMainWindowEventListener() {
     this.mainWindow.once('ready-to-show', () => {
       console.log('mainWindow ready-to-show');
       if (this.showTimer)
         clearTimeout(this.showTimer);
-      wrt.hideSplashScreen(0);
-      if (this.profileDelegate.isPreloading())
-        return;
-      this.show();
+
+      if (this.splashShown)
+        this.hideSplashScreen('first-paint');
+      else
+        this.show();
     });
 
     this.mainWindow.webContents.on('did-start-loading', () => {
@@ -196,7 +224,9 @@ export class WebApplication {
     this.mainWindow.webContents.on('did-finish-load', () => {
       console.log('webContents did-finish-load');
       this.loadFinished = true;
-      wrt.hideSplashScreen(1);
+      if (this.splashShown)
+        this.hideSplashScreen('complete');
+
       addonManager.emit('contentDidFinishLoad', this.mainWindow.id);
       if (wrt.isIMEWebApp()) {
         this.activateIMEWebHelperClient();
@@ -219,8 +249,8 @@ export class WebApplication {
     if (this.profileDelegate.isPreloading())
       return;
 
-    let splashShown = wrt.showSplashScreen();
-    if (splashShown || !this.profileDelegate.needShowTimer())
+    this.splashShown = wrt.showSplashScreen();
+    if (this.splashShown || !this.profileDelegate.needShowTimer())
       return;
 
     this.showTimer = setTimeout(() => {
@@ -363,6 +393,9 @@ export class WebApplication {
   }
 
   show() {
+    if (this.profileDelegate.isPreloading()) {
+      return;
+    }
     console.log('WebApplication : show');
     if (this.profileDelegate.backgroundExecutable()) {
       console.log('skip showing while backgroundExecution mode');
@@ -373,7 +406,6 @@ export class WebApplication {
         this.windowList[this.windowList.length - 1].moveTop();
       }
     }
-    this.profileDelegate.show();
   }
 
   private closeWindows() {