From: Youngsoo Choi Date: Mon, 26 Dec 2016 15:23:50 +0000 (+0900) Subject: Defer main loop until window is completely closed X-Git-Tag: submit/tizen_3.0/20161227.152031~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38e9ba832327c75448136718b1240b23f8af07b4;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Defer main loop until window is completely closed When uninstalling a webapp is performed while running the webapp, there's no enough time for termination of render thread by |OnTerminate|. In that case, the life-cycle of main loop needs to be guaranteed until closing window callback is called. So, this CL defers main loop until window is completely closed and removes previously implemented timer for the termination. Bug: TSAM-12072 Url: http://suprem.sec.samsung.net/jira/browse/TSAM-12072 Change-Id: I095d522f70d1c1759d07f697a179986fea7ebab5 Signed-off-by: Youngsoo Choi --- diff --git a/runtime/browser/ime_runtime.cc b/runtime/browser/ime_runtime.cc index 9cdc3db15..0527c8387 100644 --- a/runtime/browser/ime_runtime.cc +++ b/runtime/browser/ime_runtime.cc @@ -164,6 +164,7 @@ void ImeRuntime::OnCreate() { void ImeRuntime::OnTerminate() { LOGGER(DEBUG) << "ime_app_terminate"; + ClosePageFromOnTerminate(application_); } void ImeRuntime::OnShow(int context_id, ime_context_h context) { diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc old mode 100755 new mode 100644 index 051ffe08d..a2e0c0304 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -32,6 +32,8 @@ namespace runtime { +bool Runtime::is_on_terminate_called = false; + Runtime::~Runtime() { } @@ -55,5 +57,18 @@ std::unique_ptr Runtime::MakeRuntime( } } +void Runtime::ClosePageFromOnTerminate(WebApplication* app) { + if (app) { + std::list vstack = app->view_stack(); + auto it = vstack.begin(); + if (it != vstack.end()) { + Runtime::is_on_terminate_called = true; + for (; it != vstack.end(); ++it) { + vstack.front()->SetVisibility(false); + ewk_view_page_close((*it)->evas_object()); + } + } + } +} } // namespace runtime diff --git a/runtime/browser/runtime.h b/runtime/browser/runtime.h old mode 100644 new mode 100755 index db4ef005d..b4f10291c --- a/runtime/browser/runtime.h +++ b/runtime/browser/runtime.h @@ -22,6 +22,7 @@ #include #include "common/application_data.h" +#include "runtime/browser/web_application.h" namespace runtime { @@ -31,8 +32,12 @@ class Runtime { virtual int Exec(int argc, char* argv[]) = 0; + static bool is_on_terminate_called; static std::unique_ptr MakeRuntime( common::ApplicationData* app_data); + + protected: + void ClosePageFromOnTerminate(WebApplication* app); }; } // namespace runtime diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index 0f015fe02..1d01b999a 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -33,17 +33,10 @@ #include "runtime/browser/prelauncher.h" #include "runtime/browser/preload_manager.h" -bool g_prelaunch = false; +#include "runtime/browser/ui_runtime.h" -#ifdef IME_FEATURE_SUPPORT -static Ecore_Timer* timeout = NULL; +bool g_prelaunch = false; -static Eina_Bool terminateDelayCallback(void* data) { - timeout = NULL; - ecore_main_loop_quit(); - return ECORE_CALLBACK_CANCEL; -} -#endif #ifdef WATCH_FACE_FEATURE_SUPPORT static int setWatchEnv(int argc, char **argv) { bundle *kb = NULL; @@ -139,20 +132,11 @@ int real_main(int argc, char* argv[]) { std::unique_ptr runtime = runtime::Runtime::MakeRuntime(appdata); ret = runtime->Exec(argc, argv); + if (runtime->is_on_terminate_called) { + ecore_main_loop_begin(); + } runtime.reset(); } -#ifdef IME_FEATURE_SUPPORT - if (appdata->app_type() == common::ApplicationData::IME) { - timeout = ecore_timer_add(0.5, terminateDelayCallback, NULL); - // This timer is added because of deadlock issue. - // If default keyboard is switched from webapp keyboard to tizen keyboard - // before webapp keyboard is completely loaded, main loop waits - // until webview is closed where webview is waiting to finish load. - // This timer delays main loop shutdown until webview load is finished. - // FIXME: http://suprem.sec.samsung.net/jira/browse/TSAM-11361 - ecore_main_loop_begin(); - } -#endif ewk_shutdown(); elm_shutdown(); elm_exit(); diff --git a/runtime/browser/ui_runtime.cc b/runtime/browser/ui_runtime.cc index 20dddc6be..4e20943b7 100755 --- a/runtime/browser/ui_runtime.cc +++ b/runtime/browser/ui_runtime.cc @@ -142,8 +142,7 @@ bool UiRuntime::OnCreate() { } void UiRuntime::OnTerminate() { - application_.reset(); - native_window_.reset(); + ClosePageFromOnTerminate(application_.get()); } void UiRuntime::OnPause() { diff --git a/runtime/browser/watch_runtime.cc b/runtime/browser/watch_runtime.cc index afc3dbd4e..657a7f125 100644 --- a/runtime/browser/watch_runtime.cc +++ b/runtime/browser/watch_runtime.cc @@ -99,14 +99,7 @@ bool WatchRuntime::OnCreate() { } void WatchRuntime::OnTerminate() { - if (application_) { - delete application_; - application_ = nullptr; - } - if (native_window_) { - delete native_window_; - native_window_ = nullptr; - } + ClosePageFromOnTerminate(application_); } void WatchRuntime::OnPause() { diff --git a/runtime/browser/watch_runtime.h b/runtime/browser/watch_runtime.h index 8838c0d44..94c23d2c1 100644 --- a/runtime/browser/watch_runtime.h +++ b/runtime/browser/watch_runtime.h @@ -24,7 +24,6 @@ #include "common/application_data.h" #include "runtime/browser/runtime.h" #include "runtime/browser/native_window.h" -#include "runtime/browser/web_application.h" namespace runtime { diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index d1462656a..30be5300e 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -44,6 +44,7 @@ #include "runtime/browser/vibration_manager.h" #include "runtime/browser/web_view.h" #include "runtime/browser/splash_screen.h" +#include "runtime/browser/ui_runtime.h" #include "extensions/common/xwalk_extension_server.h" #ifndef INJECTED_BUNDLE_PATH @@ -709,8 +710,12 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { } void WebApplication::OnClosedWebView(WebView* view) { - is_terminated_by_callback_ = true; - RemoveWebViewFromStack(view); + is_terminated_by_callback_ = true; + RemoveWebViewFromStack(view); + + if (runtime::Runtime::is_on_terminate_called) { + ecore_main_loop_quit(); + } } void WebApplication::OnReceivedWrtMessage(WebView* /*view*/,