Fix application launch issue. 07/180207/3
authorPrathmesh <prathmesh.m@samsung.com>
Fri, 25 May 2018 10:03:22 +0000 (15:33 +0530)
committerPrathmesh <prathmesh.m@samsung.com>
Fri, 25 May 2018 11:04:15 +0000 (16:34 +0530)
Added a default timer in case if the Rendered is not called
from engine. Show window on timer fired

Ref Patches:http://slp-info.sec.samsung.net/gerrit/#/c/3105521
http://slp-info.sec.samsung.net/gerrit/#/c/3101926

Change-Id: I28dc0192acee6ed3dbb6686aaa668552ddde2835
Signed-off-by: Prathmesh <prathmesh.m@samsung.com>
common/app_control.h
runtime/browser/ui_runtime.cc
runtime/browser/web_application.cc
runtime/browser/web_application.h

index 573d24aaf87245913924635075ea8b26e98a54c9..e0f5a4c6e8f28a034bec3274fe01c5271971a768 100644 (file)
@@ -57,8 +57,8 @@ class AppControl {
   bool LaunchRequest();
 
  private:
-  app_control_h app_control_;
   bundle* app_control_bundle_;
+  app_control_h app_control_;
 };
 
 }  // namespace common
index 7a6188f4021d7102c98011f17cedb6d1262fc4a8..bb0e11ae668b46a66d716763ea045aa2c1f0098d 100755 (executable)
@@ -135,6 +135,7 @@ bool UiRuntime::OnCreate() {
   setlocale(LC_ALL, "");
   bindtextdomain(kTextDomainRuntime, kTextLocalePath);
 
+  application_->SetTimeoutFirstFrameDelay();
   return true;
 }
 
index cfe9b0c3a769a47de9e9641960006516609dd1c1..9039ca7244952404dde88395b6f80c515d5e0b75 100755 (executable)
@@ -61,6 +61,7 @@
 #define SESSION_COUNTER_INTERVAL 0.1
 #define MAIN_LOOP_INTERVAL 1
 
+static const float FirstFrameDelayWaitTime = 2.0f;
 using namespace extensions;
 
 namespace runtime {
@@ -121,7 +122,7 @@ const char* kLocationPrivilege = "http://tizen.org/privilege/location";
 const char* kRecordPrivilege = "http://tizen.org/privilege/recorder";
 const char* kStoragePrivilege = "http://tizen.org/privilege/unlimitedstorage";
 const char* kUsermediaPrivilege = "http://tizen.org/privilege/mediacapture";
-const char* kNotiIconFile = "noti_icon.png";
+//const char* kNotiIconFile = "noti_icon.png";
 const char* kFileScheme = "file://";
 
 const char* kVisibilitySuspendFeature = "visibility,suspend";
@@ -297,13 +298,15 @@ 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)),
       has_ownership_of_ewk_context_(true),
       window_(window),
       appid_(app_data->app_id()),
       app_data_(app_data),
-      locale_manager_(new common::LocaleManager()) {
+      locale_manager_(new common::LocaleManager()),
+      firstframe_delay_timer_(NULL) {
   Initialize();
 }
 
@@ -317,12 +320,14 @@ WebApplication::WebApplication(
       lang_changed_mode_(false),
       is_terminate_called_(false),
       is_close_page_called_(false),
+      is_window_inactive_(false),
       ewk_context_(context),
       has_ownership_of_ewk_context_(false),
       window_(window),
       appid_(app_data->app_id()),
       app_data_(app_data),
-      locale_manager_(new common::LocaleManager()) {
+      locale_manager_(new common::LocaleManager()),
+      firstframe_delay_timer_(NULL) {
   Initialize();
 }
 
@@ -647,6 +652,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;
@@ -662,6 +668,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)";
@@ -675,6 +682,7 @@ void WebApplication::Suspend() {
 }
 
 void WebApplication::Terminate() {
+  is_window_inactive_ = false;
   // Just process closing page once.
   if (is_terminate_called_ || is_close_page_called_)
     return;
@@ -704,6 +712,7 @@ void WebApplication::ProcessClosingPage() {
   ecore_main_loop_begin();
   ecore_timer_del(main_loop.timer);
   ecore_timer_del(session_counter.timer);
+  UnsetTimeout();
 }
 
 void WebApplication::ClosePage() {
@@ -1206,8 +1215,12 @@ void WebApplication::OnRendered(WebView* view) {
   LOGGER(DEBUG) << "Rendered";
   splash_screen_->HideSplashScreen(SplashScreen::HideReason::RENDERED);
 
+  if (firstframe_delay_timer_) {
+    UnsetTimeout();
+  }
+
   // Do not show(), active() for language change
-  if(lang_changed_mode_ == false){
+  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)) {
@@ -1519,4 +1532,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) << "FrameRendered not obtained from engine. Show window";
+  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 99e56d06efea56ead196527bc2e99eee1b1bc9f5..a724a09026f040e87ffe62204148eebbc2fadd85 100755 (executable)
@@ -60,6 +60,11 @@ class WebApplication : public WebView::EventListener {
   std::string data_path() const { return app_data_path_; }
   bool launched() const { return launched_; }
   std::list<WebView*> view_stack() const { return view_stack_; }
+  /*
+   * @function SetTimeoutFirstFrameDelay
+   * @desc     Sets a fixed timer of 2 sec from the app create time
+   */
+  void SetTimeoutFirstFrameDelay();
 
   virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
   virtual void OnClosedWebView(WebView* view);
@@ -131,12 +136,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_;
@@ -151,6 +160,7 @@ class WebApplication : public WebView::EventListener {
   std::string csp_rule_;
   std::string csp_report_rule_;
   VCWebView* vc_webview_;
+  Ecore_Timer* firstframe_delay_timer_;
 };
 
 }  // namespace runtime