From 1309299e847dd345aae5128037763ceef24f7040 Mon Sep 17 00:00:00 2001 From: "prathmesh.m" Date: Fri, 5 Oct 2018 17:25:35 +0530 Subject: [PATCH] Handle app exit when triggered from platform - 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 --- runtime/browser/web_application.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 43be4fb..4a8434d 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -62,6 +62,11 @@ #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(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); -- 2.7.4