Handle app exit when triggered from platform 20/190820/6
authorprathmesh.m <prathmesh.m@samsung.com>
Fri, 5 Oct 2018 11:55:35 +0000 (17:25 +0530)
committerjaekuk lee <juku1999@samsung.com>
Wed, 10 Oct 2018 00:54:51 +0000 (00:54 +0000)
- Issue: Crash occured on termination is triggered by platform
  (Home Key-> Exit all, app_launcher)
- Defer the ecore loop quit untill last idler is executed
- Lower the elm win instead of hiding the evas object
  to avoid flickring

Change-Id: Idab786b6dd1ee04062433c81811cd9999b19e905
Signed-off-by: prathmesh.m <prathmesh.m@samsung.com>
runtime/browser/web_application.cc

index 43be4fb11123690365e6b0ca7510789f9c049ead..4a8434d9f79df59a074e07afe2a383178dcd8f6d 100755 (executable)
 #define MAIN_LOOP_INTERVAL 1
 
 static const float FirstFrameDelayWaitTime = 2.0f;
+// keeps tracks of the added idlers
+int idler_count = 0;
+// Identifies the last idler
+bool idler_exit_loop = false;
+
 using namespace extensions;
 
 namespace runtime {
@@ -741,8 +746,13 @@ void WebApplication::ClosePage() {
 }
 
 void WebApplication::Exit() {
+  // loop begin is called only when app is terminated from platform.
+  //  So do not stop the loop here. Loop needs to be stopped when the
+  //  last view is completely deleted.
+  // App loop exit is not required in case platform triggers the app
+  //  exit
   if (!is_terminate_called_)
-    ecore_main_loop_quit();
+    return;
 
   switch (app_data_->app_type()) {
     case common::ApplicationData::AppType::UI:
@@ -806,9 +816,12 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) {
 #if !defined(TIZEN_PRODUCT_TV)
     // Hide the window object for preventing the white screen
     // during termination of web application.
-    evas_object_hide(window_->evas_object());
+    window_->InActive();
     Exit();
 #endif
+    if (!is_terminate_called_) {
+      idler_exit_loop = true;
+    }
   } else if (current != view_stack_.front()) {
     view_stack_.front()->SetVisibility(true);
     window_->SetContent(view_stack_.front()->evas_object());
@@ -817,10 +830,21 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) {
     vc_webview_->vc_webview_set_view(view_stack_.front()->evas_object());
   }
 
+  // Increment idler count. Will be decremented
+  // when idler is executed
+  idler_count++;
   // Delete after the callback context(for ewk view) was not used
   ecore_idler_add([](void* view) {
                     WebView* obj = static_cast<WebView*>(view);
                     delete obj;
+                    idler_count--;
+                    if (idler_count == 0 && idler_exit_loop) {
+                      LOGGER(DEBUG) << "Quit Loop on idler done";
+                      // Quit the loop created by crosswalk during close
+                      // page after making sure this is the last idler that
+                      // is called
+                      ecore_main_loop_quit();
+                    }
                     return EINA_FALSE;
                   },
                   view);