[compatibility] 16/170216/5 accepted/tizen/4.0/unified/20180227.151543 submit/tizen_4.0/20180227.072725
authordeepti <d.saraswat@samsung.com>
Wed, 14 Feb 2018 06:45:06 +0000 (12:15 +0530)
committerdeepti <d.saraswat@samsung.com>
Mon, 19 Feb 2018 14:09:51 +0000 (19:39 +0530)
1)Don't show window in suspend state
2)Show window object if there's delay in receiving frame rendered event

1)Window is shown even after app is suspended
Window is shown on receiving frame,rendered call back. frame,rendered call back is invoking for every frame load Measure:
Maintain a state variable for suspend. In suspended state don't show window on frame,rendered call back
2)xwalk shows window object once frame rendered callback is
received. For this app, before frame rendered step is reached, alert
function (synchronized job) is used which suspends the engine and frame
rendered event is never emitted
Provide a fallback mechanism from xwalk side to show the window irrespectively after a certain time

[Reference]
http://slp-info.sec.samsung.net/gerrit/#/c/3062458/
http://slp-info.sec.samsung.net/gerrit/#/c/3105521/
signed-off-by: deepti <d.saraswat@samsung.com>

Change-Id: I3d8fb6b1a421a46ce135d14e754b2549fec05f7f

runtime/browser/ui_runtime.cc
runtime/browser/web_application.cc
runtime/browser/web_application.h

index 9ea592b04ce351d353dd54379e061bea2a4e63a2..37212ddccbd67dcae1c9334cee2f7e41bfd2bada 100755 (executable)
@@ -151,6 +151,8 @@ bool UiRuntime::OnCreate() {
   setlocale(LC_ALL, "");
   bindtextdomain(kTextDomainRuntime, kTextLocalePath);
 
+  application_->SetTimeoutFirstFrameDelay();
+
   return true;
 }
 
index 0963b0fef6c848d46d8661c483ca364d56041405..202095179b7bbff6cc5154c02a33d4e5c9bc1086 100755 (executable)
@@ -60,6 +60,8 @@
 #define SESSION_COUNTER_INTERVAL 0.1
 #define MAIN_LOOP_INTERVAL 1
 
+static const float FirstFrameDelayWaitTime = 2.0f;
+
 using namespace extensions;
 
 namespace runtime {
@@ -321,8 +323,10 @@ WebApplication::WebApplication(
       lang_changed_mode_(false),
       is_terminate_called_(false),
       is_close_page_called_(false),
+      is_window_inactive_(false),
       ewk_context_(
           ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)),
+      firstframe_delay_timer_(NULL),
       has_ownership_of_ewk_context_(true),
       window_(window),
       appid_(app_data->app_id()),
@@ -341,7 +345,9 @@ WebApplication::WebApplication(
       lang_changed_mode_(false),
       is_terminate_called_(false),
       is_close_page_called_(false),
+      is_window_inactive_(false),
       ewk_context_(context),
+      firstframe_delay_timer_(NULL),
       has_ownership_of_ewk_context_(false),
       window_(window),
       appid_(app_data->app_id()),
@@ -679,6 +685,7 @@ void WebApplication::Resume() {
   if (view_stack_.size() > 0 && view_stack_.front() != NULL)
     view_stack_.front()->SetVisibility(true);
 
+  is_window_inactive_ = false;
   if (app_data_->setting_info() != NULL &&
       app_data_->setting_info()->background_support_enabled()) {
     return;
@@ -694,6 +701,7 @@ void WebApplication::Suspend() {
   if (view_stack_.size() > 0 && view_stack_.front() != NULL)
     view_stack_.front()->SetVisibility(false);
 
+  is_window_inactive_ = true;
   if (app_data_->setting_info() != NULL &&
       app_data_->setting_info()->background_support_enabled()) {
     LOGGER(DEBUG) << "gone background (backgroud support enabed)";
@@ -708,6 +716,7 @@ void WebApplication::Suspend() {
 
 void WebApplication::Terminate() {
   // Just process closing page once.
+  is_window_inactive_ = false;
   if (is_terminate_called_ || is_close_page_called_)
     return;
 
@@ -736,6 +745,7 @@ void WebApplication::ProcessClosingPage() {
   ecore_main_loop_begin();
   ecore_timer_del(main_loop.timer);
   ecore_timer_del(session_counter.timer);
+  UnsetTimeout();
 }
 
 void WebApplication::ClosePage() {
@@ -1214,14 +1224,19 @@ void WebApplication::OnRendered(WebView* view) {
   LOGGER(DEBUG) << "Rendered";
   splash_screen_->HideSplashScreen(SplashScreen::HideReason::RENDERED);
 
+  if (firstframe_delay_timer_) {
+    UnsetTimeout();
+  }
+
   // Set web view into Web voice touch agent
   if (NULL != vc_webview_) {
     vc_webview_->vc_webview_set_view(view->evas_object());
   }
 
   // Do not show(), active() for language change
-  if(lang_changed_mode_ == false){
-      // Show window after frame rendered.
+  if(lang_changed_mode_ == false &&
+    is_window_inactive_ == false) {
+       // Show window after frame rendered.
       if (common::getProfile() == common::kPROFILE_MOBILE) {
         if (common::utils::StartsWith(view->GetUrl(), kFileScheme)) {
           window_->Show();
@@ -1542,4 +1557,31 @@ void WebApplication::OnUsermediaPermissionRequest(
   popup->Show();
 }
 
+void WebApplication::SetTimeoutFirstFrameDelay() {
+  LOGGER(DEBUG);
+  firstframe_delay_timer_ = ecore_timer_add(
+    FirstFrameDelayWaitTime,
+    FirstFrameDelayTimerCallback, this);
+}
+
+Eina_Bool WebApplication::FirstFrameDelayTimerCallback(void* data) {
+  LOGGER(DEBUG);
+  WebApplication* This = static_cast<WebApplication*>(data);
+  /* Do not show(), active() when window is already in background */
+  if(This->is_window_inactive_ == false) {
+    This->window_->Show();
+    This->window_->Active();
+  }
+  This->firstframe_delay_timer_ = NULL;
+  return ECORE_CALLBACK_CANCEL;
+}
+
+void WebApplication::UnsetTimeout() {
+  LOGGER(DEBUG);
+  if (firstframe_delay_timer_) {
+    ecore_timer_del(firstframe_delay_timer_);
+    firstframe_delay_timer_ = NULL;
+  }
+}
+
 }  // namespace runtime
index d85aa6e5220d4f342336a2666389c3d24167ab25..a7eead7f4518dcd9d6a399fac37ee811d9c5d3f2 100755 (executable)
@@ -112,6 +112,8 @@ class WebApplication : public WebView::EventListener {
     Ecore_Timer* timer;
   } main_loop, session_counter;
 
+  void SetTimeoutFirstFrameDelay();
+
  private:
   bool Initialize();
 
@@ -132,12 +134,16 @@ class WebApplication : public WebView::EventListener {
       bool tizenWebKitCompatibilityEnabled() const { return (m_major && m_major < 3); }
   } m_tizenCompatibilitySettings;
 
+  static Eina_Bool FirstFrameDelayTimerCallback(void* data);
+  void UnsetTimeout();
+
   bool launched_;
   bool debug_mode_;
   bool verbose_mode_;
   bool lang_changed_mode_;
   bool is_terminate_called_;
   bool is_close_page_called_;
+  bool is_window_inactive_;
   Ewk_Context* ewk_context_;
   bool has_ownership_of_ewk_context_;
   NativeWindow* window_;
@@ -152,6 +158,8 @@ class WebApplication : public WebView::EventListener {
   std::string csp_rule_;
   std::string csp_report_rule_;
   VCWebView* vc_webview_;
+
+  Ecore_Timer* firstframe_delay_timer_;
 };
 
 }  // namespace runtime