From: DongHyun Song Date: Fri, 25 Jun 2021 05:38:55 +0000 (+0900) Subject: [VideoSplash] Fix focus issue of VSS and refactors X-Git-Tag: submit/tizen/20210706.160021^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78bf70348608dfb192f43661fa0093da6cce8b5a;p=platform%2Fframework%2Fweb%2Fwrtjs.git [VideoSplash] Fix focus issue of VSS and refactors [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 Signed-off-by: DongHyun Song --- diff --git a/wrt_app/common/web_application_delegate.ts b/wrt_app/common/web_application_delegate.ts index b31a4d9..8d80b78 100644 --- a/wrt_app/common/web_application_delegate.ts +++ b/wrt_app/common/web_application_delegate.ts @@ -44,5 +44,4 @@ export class WebApplicationDelegate { needShowTimer() { return true; } onDidFinishLoad() { } profileName() { return 'common' } - show() { } } diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index 3a1d846..2f8a850 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -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]); } }); diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index bbda5e2..ade4147 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -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') { diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 8a39aaa..4d4872a 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -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() {