From ccb5936a271fc9502fb3ba8b82373fa92d99df80 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Wed, 4 Jan 2017 18:01:10 +0900 Subject: [PATCH 01/16] Assure proper termination using context session Current main loop quits when closing window callback is called. Btw, it does not assure proper termination of changing watch face because context session stops too early and callback can not be called and then dead lock happens. So, this CL extends the main loop until all the context sessions are finished and covers following termination scenarios. * h/w back key * exit pop up menu * exit command |pkgcmd -k| * uninstall command |pkgcmd -u| while webapp runs * changing watch face Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2765 Change-Id: I1767ef5f14e393ffc59668b0b9925d781abfd2f5 Signed-off-by: Youngsoo Choi --- .../xwalk_extension_renderer_controller.cc | 7 +++ .../renderer/xwalk_extension_renderer_controller.h | 1 + runtime/browser/runtime_process.cc | 12 ++++- runtime/browser/web_application.cc | 63 +++++++++++++++++++--- runtime/browser/web_application.h | 2 + 5 files changed, 77 insertions(+), 8 deletions(-) diff --git a/extensions/renderer/xwalk_extension_renderer_controller.cc b/extensions/renderer/xwalk_extension_renderer_controller.cc index 59e45b7..01c1ece 100755 --- a/extensions/renderer/xwalk_extension_renderer_controller.cc +++ b/extensions/renderer/xwalk_extension_renderer_controller.cc @@ -22,6 +22,9 @@ namespace extensions { +// static +int XWalkExtensionRendererController::plugin_session_count = 0; + namespace { void CreateExtensionModules(XWalkExtensionClient* client, @@ -81,12 +84,16 @@ void XWalkExtensionRendererController::DidCreateScriptContext( CreateExtensionModules(extensions_client_.get(), module_system); module_system->Initialize(); + plugin_session_count++; + LOGGER(DEBUG) << "plugin_session_count : " << plugin_session_count; } void XWalkExtensionRendererController::WillReleaseScriptContext( v8::Handle context) { v8::Context::Scope contextScope(context); XWalkModuleSystem::ResetModuleSystemFromContext(context); + plugin_session_count--; + LOGGER(DEBUG) << "plugin_session_count : " << plugin_session_count; } void XWalkExtensionRendererController::OnReceivedIPCMessage( diff --git a/extensions/renderer/xwalk_extension_renderer_controller.h b/extensions/renderer/xwalk_extension_renderer_controller.h index 4927d21..95e3145 100755 --- a/extensions/renderer/xwalk_extension_renderer_controller.h +++ b/extensions/renderer/xwalk_extension_renderer_controller.h @@ -20,6 +20,7 @@ class XWalkExtensionClient; class XWalkExtensionRendererController { public: static XWalkExtensionRendererController& GetInstance(); + static int plugin_session_count; void DidCreateScriptContext(v8::Handle context); void WillReleaseScriptContext(v8::Handle context); diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index 859aa3a..83d7645 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -28,6 +28,7 @@ #include "common/command_line.h" #include "common/logger.h" #include "common/profiler.h" +#include "extensions/renderer/xwalk_extension_renderer_controller.h" #include "runtime/browser/runtime.h" #include "runtime/common/constants.h" #include "runtime/browser/prelauncher.h" @@ -35,6 +36,7 @@ #include "runtime/browser/ui_runtime.h" +using namespace extensions; bool g_prelaunch = false; #ifdef WATCH_FACE_FEATURE_SUPPORT @@ -132,16 +134,22 @@ 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) { - LOGGER(INFO) << "Defer termination of main loop"; + if (ret) + LOGGER(ERROR) << "Exec returns non zero."; + LOGGER(DEBUG) << "plugin_session_count : " << + XWalkExtensionRendererController::plugin_session_count; + if (XWalkExtensionRendererController::plugin_session_count > 0) { + LOGGER(DEBUG) << "Defer termination of main loop"; ecore_main_loop_begin(); } runtime.reset(); } + LOGGER(DEBUG) << "ewk_shutdown"; ewk_shutdown(); elm_shutdown(); elm_exit(); + LOGGER(DEBUG) << "EXIT_SUCCESS"; return EXIT_SUCCESS; } diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 9a5d50b..68143a8 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -37,6 +37,7 @@ #include "common/profiler.h" #include "common/resource_manager.h" #include "common/string_utils.h" +#include "extensions/renderer/xwalk_extension_renderer_controller.h" #include "runtime/browser/native_window.h" #include "runtime/browser/notification_manager.h" #include "runtime/browser/popup.h" @@ -51,6 +52,10 @@ #error INJECTED_BUNDLE_PATH is not set. #endif +#define TIMER_INTERVAL 0.1 + +using namespace extensions; + namespace runtime { namespace { @@ -222,8 +227,10 @@ static void InitializeNotificationCallback(Ewk_Context* ewk_context, static Eina_Bool ExitAppIdlerCallback(void* data) { WebApplication* app = static_cast(data); - if (app) + if (app) { + LOGGER(DEBUG) << "Terminate"; app->Terminate(); + } return ECORE_CALLBACK_CANCEL; } @@ -285,6 +292,7 @@ WebApplication::WebApplication( debug_mode_(false), verbose_mode_(false), lang_changed_mode_(false), + is_terminate_called_(false), ewk_context_( ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)), has_ownership_of_ewk_context_(true), @@ -303,6 +311,7 @@ WebApplication::WebApplication( : launched_(false), debug_mode_(false), verbose_mode_(false), + is_terminate_called_(false), ewk_context_(context), has_ownership_of_ewk_context_(false), window_(window), @@ -637,23 +646,28 @@ void WebApplication::Suspend() { } void WebApplication::Terminate() { + is_terminate_called_ = true; if (terminator_) { + LOGGER(DEBUG) << "terminator_"; terminator_(); } else { + LOGGER(ERROR) << "There's no registered terminator."; elm_exit(); } auto extension_server = extensions::XWalkExtensionServer::GetInstance(); - LOGGER(INFO) << "Shutdown extension server"; + LOGGER(DEBUG) << "Shutdown extension server"; extension_server->Shutdown(); } void WebApplication::ClosePageFromOnTerminate() { + LOGGER(DEBUG); auto it = view_stack_.begin(); if (it != view_stack_.end()) { runtime::Runtime::is_on_terminate_called = true; for (; it != view_stack_.end(); ++it) { (*it)->ReplyToJavascriptDialog(); view_stack_.front()->SetVisibility(false); + LOGGER(DEBUG) << "ewk_view_page_close"; ewk_view_page_close((*it)->evas_object()); } } @@ -692,7 +706,13 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { } if (view_stack_.size() == 0) { - Terminate(); + // If |Terminate()| hasn't been called, + // main loop shouldn't be terminated here. + if (!is_terminate_called_) { + auto extension_server = XWalkExtensionServer::GetInstance(); + LOGGER(DEBUG) << "Shutdown extension server"; + extension_server->Shutdown(); + } } else if (current != view_stack_.front()) { view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); @@ -707,14 +727,43 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { view); } +Eina_Bool WebApplication::CheckPluginSession(void* user_data) +{ + WebApplication* that = static_cast(user_data); + if(XWalkExtensionRendererController::plugin_session_count > 0) { + LOGGER(ERROR) << "plugin_session_count : " << + XWalkExtensionRendererController::plugin_session_count; + return ECORE_CALLBACK_RENEW; + } + LOGGER(DEBUG) << "plugin_session_count : " << + XWalkExtensionRendererController::plugin_session_count; + LOGGER(DEBUG) << "Execute deferred termination of main loop"; + if (that->is_terminate_called_) { + ecore_main_loop_quit(); + } else { + if (that->terminator_) { + LOGGER(DEBUG) << "terminator_"; + that->terminator_(); + } else { + LOGGER(ERROR) << "There's no registered terminator."; + elm_exit(); + } + } + return ECORE_CALLBACK_CANCEL; +} + void WebApplication::OnClosedWebView(WebView* view) { + Ecore_Timer* timeout_id = NULL; // Reply to javascript dialog for preventing freeze issue. view->ReplyToJavascriptDialog(); RemoveWebViewFromStack(view); - if (runtime::Runtime::is_on_terminate_called) { - LOGGER(INFO) << "Execute deferred termination of main loop"; - ecore_main_loop_quit(); + LOGGER(DEBUG) << "plugin_session_count : " << + XWalkExtensionRendererController::plugin_session_count; + if (XWalkExtensionRendererController::plugin_session_count > 0) { + timeout_id = ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this); + if (!timeout_id) + LOGGER(ERROR) << "It's failed to create timer"; } } @@ -831,6 +880,7 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { if(enabled) view->EvalJavascript(kBackKeyEventScript); if (!view->Backward()) { + LOGGER(DEBUG) << "Terminate"; Terminate(); } } @@ -846,6 +896,7 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { (app_data_->widget_info() != NULL && app_data_->widget_info()->view_modes() == "windowed")) { if (!view->Backward()) { + LOGGER(DEBUG) << "Terminate"; Terminate(); } } diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 751e809..48665e8 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -106,6 +106,7 @@ class WebApplication : public WebView::EventListener { #ifdef MANUAL_ROTATE_FEATURE_SUPPORT virtual void OnRotatePrepared(WebView* view); #endif // MANUAL_ROTATE_FEATURE_SUPPORT + static Eina_Bool CheckPluginSession(void* user_data); private: bool Initialize(); @@ -130,6 +131,7 @@ class WebApplication : public WebView::EventListener { bool debug_mode_; bool verbose_mode_; bool lang_changed_mode_; + bool is_terminate_called_; Ewk_Context* ewk_context_; bool has_ownership_of_ewk_context_; NativeWindow* window_; -- 2.7.4 From a3069e4415e651b93ca597d2503c4792b16f9194 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 10 Jan 2017 14:52:26 +0900 Subject: [PATCH 02/16] Remove unused varialbe is_on_terminate_called Since the termination sequence was unified using context session, the variable is_on_terminate_called hasn't been used. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2769 Change-Id: Ie30e501d1c9ed1934c9cea560922c69efe79b810 Signed-off-by: Youngsoo Choi --- runtime/browser/runtime.cc | 2 -- runtime/browser/runtime.h | 1 - runtime/browser/web_application.cc | 1 - 3 files changed, 4 deletions(-) diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc index bba1168..4298837 100644 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -32,8 +32,6 @@ namespace runtime { -bool Runtime::is_on_terminate_called = false; - Runtime::~Runtime() { } diff --git a/runtime/browser/runtime.h b/runtime/browser/runtime.h index b4f1029..00dea07 100755 --- a/runtime/browser/runtime.h +++ b/runtime/browser/runtime.h @@ -32,7 +32,6 @@ 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); diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 68143a8..e0ef6a5 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -663,7 +663,6 @@ void WebApplication::ClosePageFromOnTerminate() { LOGGER(DEBUG); auto it = view_stack_.begin(); if (it != view_stack_.end()) { - runtime::Runtime::is_on_terminate_called = true; for (; it != view_stack_.end(); ++it) { (*it)->ReplyToJavascriptDialog(); view_stack_.front()->SetVisibility(false); -- 2.7.4 From aca556ce936f3967e8dcc017b0d9279951897d18 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Thu, 12 Jan 2017 14:52:13 +0900 Subject: [PATCH 03/16] Locate ewk_view_page_close in extended main loop Sometimes, closing page callbkack is missing when the callback comes between terminating main loop and creating extended main loop. In that case, deadlock situation happens. To avoid the issue, the ewk_view_page_close needs to be called in extended main loop to assure receiving the callback. Also, evas object needs to be deleted when it's valid. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2782 Change-Id: I7a86121bc7c78225b54bb6fe22b934f62615a46d Signed-off-by: Youngsoo Choi --- runtime/browser/ime_runtime.cc | 5 ++++- runtime/browser/ime_runtime.h | 1 + runtime/browser/runtime.cc | 25 ++++++++++++++++++++++--- runtime/browser/runtime.h | 11 ++++++++++- runtime/browser/runtime_process.cc | 11 ++--------- runtime/browser/ui_runtime.cc | 6 +++++- runtime/browser/ui_runtime.h | 1 + runtime/browser/watch_runtime.cc | 5 ++++- runtime/browser/watch_runtime.h | 1 + runtime/browser/web_application.cc | 31 +++++++++++++++++++++++-------- runtime/browser/web_application.h | 2 +- runtime/browser/web_view_impl.cc | 1 + 12 files changed, 75 insertions(+), 25 deletions(-) diff --git a/runtime/browser/ime_runtime.cc b/runtime/browser/ime_runtime.cc index 0527c83..78a890a 100644 --- a/runtime/browser/ime_runtime.cc +++ b/runtime/browser/ime_runtime.cc @@ -163,8 +163,11 @@ void ImeRuntime::OnCreate() { } void ImeRuntime::OnTerminate() { +} + +void ImeRuntime::Terminate() { LOGGER(DEBUG) << "ime_app_terminate"; - ClosePageFromOnTerminate(application_); + ProcessClosingPage(application_); } void ImeRuntime::OnShow(int context_id, ime_context_h context) { diff --git a/runtime/browser/ime_runtime.h b/runtime/browser/ime_runtime.h index 1284a3d..b020539 100644 --- a/runtime/browser/ime_runtime.h +++ b/runtime/browser/ime_runtime.h @@ -42,6 +42,7 @@ class ImeRuntime : public Runtime { virtual void OnHide(int context_id); virtual void OnAppControl(); + virtual void Terminate(); private: WebApplication* application_; NativeWindow* native_window_; diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc index 4298837..5861b08 100644 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -20,6 +20,7 @@ #include "common/application_data.h" #include "common/command_line.h" +#include "common/logger.h" #include "runtime/common/constants.h" #include "runtime/browser/runtime.h" #include "runtime/browser/ui_runtime.h" @@ -30,6 +31,8 @@ #include "runtime/browser/watch_runtime.h" #endif // WATCH_FACE_FEATURE_SUPPORT +#define MAIN_LOOP_INTERVAL 1 + namespace runtime { Runtime::~Runtime() { @@ -55,9 +58,25 @@ std::unique_ptr Runtime::MakeRuntime( } } -void Runtime::ClosePageFromOnTerminate(WebApplication* app) { - if (app) - app->ClosePageFromOnTerminate(); +// static +Eina_Bool Runtime::ClosePageInExtendedMainLoop(void* user_data) +{ + LOGGER(DEBUG); + struct Timer* main_loop = static_cast(user_data); + main_loop->application->ClosePage(); + return ECORE_CALLBACK_CANCEL; +} + +void Runtime::ProcessClosingPage(WebApplication* application) { + LOGGER(DEBUG); + if (application) { + struct Timer main_loop; + main_loop.application = application; + main_loop.timer = ecore_timer_add(MAIN_LOOP_INTERVAL, ClosePageInExtendedMainLoop, &main_loop); + LOGGER(DEBUG) << "Defer termination of main loop"; + ecore_main_loop_begin(); + ecore_timer_del(main_loop.timer); + } } } // namespace runtime diff --git a/runtime/browser/runtime.h b/runtime/browser/runtime.h index 00dea07..63ddc97 100755 --- a/runtime/browser/runtime.h +++ b/runtime/browser/runtime.h @@ -29,6 +29,7 @@ namespace runtime { class Runtime { public: virtual ~Runtime() = 0; + virtual void Terminate() = 0; virtual int Exec(int argc, char* argv[]) = 0; @@ -36,7 +37,15 @@ class Runtime { common::ApplicationData* app_data); protected: - void ClosePageFromOnTerminate(WebApplication* app); + void ProcessClosingPage(WebApplication* application); + + private: + static Eina_Bool ClosePageInExtendedMainLoop(void* user_data); + struct Timer + { + WebApplication* application; + Ecore_Timer* timer; + }; }; } // namespace runtime diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index 83d7645..757fdfa 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -128,20 +128,13 @@ int real_main(int argc, char* argv[]) { #endif // WATCH_FACE_FEATURE_SUPPORT } - int ret = 0; // Runtime's destructor should be called before ewk_shutdown() { std::unique_ptr runtime = runtime::Runtime::MakeRuntime(appdata); - ret = runtime->Exec(argc, argv); - if (ret) + if (runtime->Exec(argc, argv)) LOGGER(ERROR) << "Exec returns non zero."; - LOGGER(DEBUG) << "plugin_session_count : " << - XWalkExtensionRendererController::plugin_session_count; - if (XWalkExtensionRendererController::plugin_session_count > 0) { - LOGGER(DEBUG) << "Defer termination of main loop"; - ecore_main_loop_begin(); - } + runtime->Terminate(); runtime.reset(); } LOGGER(DEBUG) << "ewk_shutdown"; diff --git a/runtime/browser/ui_runtime.cc b/runtime/browser/ui_runtime.cc index 4e20943..41fa8d9 100755 --- a/runtime/browser/ui_runtime.cc +++ b/runtime/browser/ui_runtime.cc @@ -142,7 +142,11 @@ bool UiRuntime::OnCreate() { } void UiRuntime::OnTerminate() { - ClosePageFromOnTerminate(application_.get()); +} + +void UiRuntime::Terminate() { + LOGGER(DEBUG); + ProcessClosingPage(application_.get()); } void UiRuntime::OnPause() { diff --git a/runtime/browser/ui_runtime.h b/runtime/browser/ui_runtime.h index 7aff1f7..1625abd 100644 --- a/runtime/browser/ui_runtime.h +++ b/runtime/browser/ui_runtime.h @@ -44,6 +44,7 @@ class UiRuntime : public Runtime { virtual void OnAppControl(app_control_h app_control); virtual void OnLanguageChanged(const std::string& language); virtual void OnLowMemory(); + virtual void Terminate(); private: void ResetWebApplication(NativeWindow::Type windowType); diff --git a/runtime/browser/watch_runtime.cc b/runtime/browser/watch_runtime.cc index 657a7f1..f166e72 100644 --- a/runtime/browser/watch_runtime.cc +++ b/runtime/browser/watch_runtime.cc @@ -99,7 +99,10 @@ bool WatchRuntime::OnCreate() { } void WatchRuntime::OnTerminate() { - ClosePageFromOnTerminate(application_); +} + +void WatchRuntime::Terminate() { + ProcessClosingPage(application_); } void WatchRuntime::OnPause() { diff --git a/runtime/browser/watch_runtime.h b/runtime/browser/watch_runtime.h index 94c23d2..7fd5c3a 100644 --- a/runtime/browser/watch_runtime.h +++ b/runtime/browser/watch_runtime.h @@ -46,6 +46,7 @@ class WatchRuntime : public Runtime { virtual void OnAmbientTick(watch_time_h watch_time); virtual void OnAmbientChanged(bool ambient_mode); + virtual void Terminate(); private: WebApplication* application_; NativeWindow* native_window_; diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index e0ef6a5..e11d9e0 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -659,15 +659,33 @@ void WebApplication::Terminate() { extension_server->Shutdown(); } -void WebApplication::ClosePageFromOnTerminate() { +void WebApplication::ClosePage() { LOGGER(DEBUG); + int valid_evas_object_count = 0; auto it = view_stack_.begin(); if (it != view_stack_.end()) { for (; it != view_stack_.end(); ++it) { (*it)->ReplyToJavascriptDialog(); view_stack_.front()->SetVisibility(false); - LOGGER(DEBUG) << "ewk_view_page_close"; - ewk_view_page_close((*it)->evas_object()); + if (ewk_view_page_close((*it)->evas_object())) { + LOGGER(DEBUG) << "ewk_view_page_close returns true"; + valid_evas_object_count++; + } else { + LOGGER(DEBUG) << "ewk_view_page_close returns false"; + } + } + } + if (valid_evas_object_count == 0) { + if (is_terminate_called_) { + ecore_main_loop_quit(); + } else { + if (terminator_) { + LOGGER(DEBUG) << "terminator_"; + terminator_(); + } else { + LOGGER(ERROR) << "There's no registered terminator."; + elm_exit(); + } } } } @@ -759,11 +777,8 @@ void WebApplication::OnClosedWebView(WebView* view) { LOGGER(DEBUG) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; - if (XWalkExtensionRendererController::plugin_session_count > 0) { - timeout_id = ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this); - if (!timeout_id) - LOGGER(ERROR) << "It's failed to create timer"; - } + if (!ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this)) + LOGGER(ERROR) << "It's failed to create timer"; } void WebApplication::OnReceivedWrtMessage(WebView* view, diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 48665e8..3fdbdfe 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -52,7 +52,7 @@ class WebApplication : public WebView::EventListener { void Suspend(); void Terminate(); - void ClosePageFromOnTerminate(); + void ClosePage(); std::string data_path() const { return app_data_path_; } void set_terminator(std::function terminator) { terminator_ = terminator; diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index cc52275..162bca9 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -633,6 +633,7 @@ void WebViewImpl::InitWindowCreateCallback() { auto close_callback = [](void* user_data, Evas_Object*, void*) { + LOGGER(DEBUG) << "close_callback is called"; WebViewImpl* self = static_cast(user_data); if (!self->listener_) { return; -- 2.7.4 From 7805d199bbb9ce9065fb4f3a77180879c663f1e7 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 17 Jan 2017 14:07:27 +0900 Subject: [PATCH 04/16] Add elementary APIs for running web app without wrt-loader The |elm_init| and |elm_config_cache_flush_enabled_set| are missing when launching web app without wrt-loader. bug: http://suprem.sec.samsung.net/jira/browse/TWF-2800 Change-Id: I5effca0e67561b9ed1e900e6d5b86087143dfc81 Signed-off-by: Youngsoo Choi --- runtime/browser/runtime_process.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index 757fdfa..a085bbc 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -148,10 +148,12 @@ int real_main(int argc, char* argv[]) { __attribute__((visibility("default"))) int main(int argc, char* argv[]) { + elm_init(argc, argv); + elm_config_cache_flush_enabled_set(EINA_TRUE); + if (strcmp(argv[0], "/usr/bin/wrt-loader") == 0) { - elm_init(argc, argv); - elm_config_cache_flush_enabled_set(EINA_TRUE); auto preload = [argv](void) { + LOGGER(DEBUG) << "run with wrt-loader"; g_prelaunch = true; ewk_init(); char* chromium_arg_options[] = { @@ -172,6 +174,7 @@ int main(int argc, char* argv[]) { auto prelaunch = runtime::PreLauncher::Prelaunch; return prelaunch(argc, argv, preload, did_launch, real_main); } else { + LOGGER(DEBUG) << "run without wrt-loader"; return real_main(argc, argv); } } -- 2.7.4 From ef77d1d5e4c12b9a657da10cb4decb0b7d96349c Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 16 Jan 2017 12:51:12 +0900 Subject: [PATCH 05/16] Do not create extended main loop for termination by |Terminate| There are two types of termination sequences. The first one is terminated by |Terminate| and another one is terminated by |OnTerminate| triggered by application framework. In case of termination by |OnTerminate|, app f/w emits elm_shutdown that quits main loop so extended main loop is needed to finish termination sequence. Btw, in case of termination by |Terminate|, app f/w does not interrupt current main loop so it is stll alive and extended main loop is not needed. This CL introduces not to create extended main loop for the termination by |Terminate|. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2804 Change-Id: I15147c9d07ec768bdb7f8acf92e18886ec2c100d Signed-off-by: Youngsoo Choi --- runtime/browser/runtime.cc | 19 +------- runtime/browser/runtime.h | 8 ---- runtime/browser/web_application.cc | 96 ++++++++++++++++++++------------------ runtime/browser/web_application.h | 9 ++++ 4 files changed, 62 insertions(+), 70 deletions(-) diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc index 5861b08..2254bfc 100644 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -58,25 +58,10 @@ std::unique_ptr Runtime::MakeRuntime( } } -// static -Eina_Bool Runtime::ClosePageInExtendedMainLoop(void* user_data) -{ - LOGGER(DEBUG); - struct Timer* main_loop = static_cast(user_data); - main_loop->application->ClosePage(); - return ECORE_CALLBACK_CANCEL; -} - void Runtime::ProcessClosingPage(WebApplication* application) { LOGGER(DEBUG); - if (application) { - struct Timer main_loop; - main_loop.application = application; - main_loop.timer = ecore_timer_add(MAIN_LOOP_INTERVAL, ClosePageInExtendedMainLoop, &main_loop); - LOGGER(DEBUG) << "Defer termination of main loop"; - ecore_main_loop_begin(); - ecore_timer_del(main_loop.timer); - } + if (application) + application->ProcessClosingPage(); } } // namespace runtime diff --git a/runtime/browser/runtime.h b/runtime/browser/runtime.h index 63ddc97..a003dac 100755 --- a/runtime/browser/runtime.h +++ b/runtime/browser/runtime.h @@ -38,14 +38,6 @@ class Runtime { protected: void ProcessClosingPage(WebApplication* application); - - private: - static Eina_Bool ClosePageInExtendedMainLoop(void* user_data); - struct Timer - { - WebApplication* application; - Ecore_Timer* timer; - }; }; } // namespace runtime diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index e11d9e0..97d9bb3 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -52,7 +52,8 @@ #error INJECTED_BUNDLE_PATH is not set. #endif -#define TIMER_INTERVAL 0.1 +#define SESSION_COUNTER_INTERVAL 0.1 +#define MAIN_LOOP_INTERVAL 1 using namespace extensions; @@ -647,20 +648,35 @@ void WebApplication::Suspend() { void WebApplication::Terminate() { is_terminate_called_ = true; - if (terminator_) { - LOGGER(DEBUG) << "terminator_"; - terminator_(); - } else { - LOGGER(ERROR) << "There's no registered terminator."; - elm_exit(); - } - auto extension_server = extensions::XWalkExtensionServer::GetInstance(); - LOGGER(DEBUG) << "Shutdown extension server"; - extension_server->Shutdown(); + ClosePage(); +} + +// static +Eina_Bool WebApplication::ClosePageInExtendedMainLoop(void* user_data) +{ + LOGGER(DEBUG); + struct Timer* main_loop = static_cast(user_data); + main_loop->application->ClosePage(); + return ECORE_CALLBACK_CANCEL; +} + +void WebApplication::ProcessClosingPage() { + LOGGER(DEBUG); + + main_loop.application = this; + main_loop.timer = ecore_timer_add(MAIN_LOOP_INTERVAL, + ClosePageInExtendedMainLoop, &main_loop); + if (!main_loop.timer) + LOGGER(ERROR) << "It's failed to create main_loop timer"; + LOGGER(DEBUG) << "Defer termination of main loop"; + ecore_main_loop_begin(); + ecore_timer_del(main_loop.timer); + ecore_timer_del(session_counter.timer); } void WebApplication::ClosePage() { LOGGER(DEBUG); + int valid_evas_object_count = 0; auto it = view_stack_.begin(); if (it != view_stack_.end()) { @@ -675,18 +691,20 @@ void WebApplication::ClosePage() { } } } - if (valid_evas_object_count == 0) { - if (is_terminate_called_) { - ecore_main_loop_quit(); - } else { - if (terminator_) { - LOGGER(DEBUG) << "terminator_"; - terminator_(); - } else { - LOGGER(ERROR) << "There's no registered terminator."; - elm_exit(); - } - } + if (valid_evas_object_count == 0) + Exit(); +} + +void WebApplication::Exit() { + if (!is_terminate_called_) + ecore_main_loop_quit(); + + if (terminator_) { + LOGGER(DEBUG) << "terminator_"; + terminator_(); + } else { + LOGGER(ERROR) << "There's no registered terminator."; + elm_exit(); } } @@ -723,13 +741,9 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { } if (view_stack_.size() == 0) { - // If |Terminate()| hasn't been called, - // main loop shouldn't be terminated here. - if (!is_terminate_called_) { - auto extension_server = XWalkExtensionServer::GetInstance(); - LOGGER(DEBUG) << "Shutdown extension server"; - extension_server->Shutdown(); - } + auto extension_server = XWalkExtensionServer::GetInstance(); + LOGGER(DEBUG) << "Shutdown extension server"; + extension_server->Shutdown(); } else if (current != view_stack_.front()) { view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); @@ -746,7 +760,7 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { Eina_Bool WebApplication::CheckPluginSession(void* user_data) { - WebApplication* that = static_cast(user_data); + struct Timer* session_counter = static_cast(user_data); if(XWalkExtensionRendererController::plugin_session_count > 0) { LOGGER(ERROR) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; @@ -755,30 +769,22 @@ Eina_Bool WebApplication::CheckPluginSession(void* user_data) LOGGER(DEBUG) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; LOGGER(DEBUG) << "Execute deferred termination of main loop"; - if (that->is_terminate_called_) { - ecore_main_loop_quit(); - } else { - if (that->terminator_) { - LOGGER(DEBUG) << "terminator_"; - that->terminator_(); - } else { - LOGGER(ERROR) << "There's no registered terminator."; - elm_exit(); - } - } + session_counter->application->Exit(); return ECORE_CALLBACK_CANCEL; } void WebApplication::OnClosedWebView(WebView* view) { - Ecore_Timer* timeout_id = NULL; // Reply to javascript dialog for preventing freeze issue. view->ReplyToJavascriptDialog(); RemoveWebViewFromStack(view); LOGGER(DEBUG) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; - if (!ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this)) - LOGGER(ERROR) << "It's failed to create timer"; + session_counter.application = this; + session_counter.timer = ecore_timer_add(SESSION_COUNTER_INTERVAL, + CheckPluginSession, &session_counter); + if (!session_counter.timer) + LOGGER(ERROR) << "It's failed to create session_counter timer"; } void WebApplication::OnReceivedWrtMessage(WebView* view, diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 3fdbdfe..446fb49 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -53,6 +53,9 @@ class WebApplication : public WebView::EventListener { void Terminate(); void ClosePage(); + void Exit(); + void ProcessClosingPage(); + std::string data_path() const { return app_data_path_; } void set_terminator(std::function terminator) { terminator_ = terminator; @@ -107,6 +110,12 @@ class WebApplication : public WebView::EventListener { virtual void OnRotatePrepared(WebView* view); #endif // MANUAL_ROTATE_FEATURE_SUPPORT static Eina_Bool CheckPluginSession(void* user_data); + static Eina_Bool ClosePageInExtendedMainLoop(void* user_data); + struct Timer + { + WebApplication* application; + Ecore_Timer* timer; + } main_loop, session_counter; private: bool Initialize(); -- 2.7.4 From 90e768451af2f3542b90e45743d169a2a3974cde Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 16 Jan 2017 12:51:12 +0900 Subject: [PATCH 06/16] Prevent duplicated call of |Terminate| There will be duplicated call of |Terminate| in following case. When pressing back key multiple times, h/w key events emit multiple |Terminate| as they are pressed. The |Terminate| needs to be processed once. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2801 Change-Id: I16745993d60df78c04e354352066a7db7181e303 Signed-off-by: Youngsoo Choi --- runtime/browser/web_application.cc | 7 +++++++ runtime/browser/web_application.h | 1 + 2 files changed, 8 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 97d9bb3..dd6383e 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -294,6 +294,7 @@ WebApplication::WebApplication( verbose_mode_(false), lang_changed_mode_(false), is_terminate_called_(false), + is_close_page_called_(false), ewk_context_( ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)), has_ownership_of_ewk_context_(true), @@ -313,6 +314,7 @@ WebApplication::WebApplication( debug_mode_(false), verbose_mode_(false), is_terminate_called_(false), + is_close_page_called_(false), ewk_context_(context), has_ownership_of_ewk_context_(false), window_(window), @@ -647,6 +649,10 @@ void WebApplication::Suspend() { } void WebApplication::Terminate() { + // Just process closing page once. + if (is_terminate_called_ || is_close_page_called_) + return; + is_terminate_called_ = true; ClosePage(); } @@ -676,6 +682,7 @@ void WebApplication::ProcessClosingPage() { void WebApplication::ClosePage() { LOGGER(DEBUG); + is_close_page_called_ = true; int valid_evas_object_count = 0; auto it = view_stack_.begin(); diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 446fb49..f35fd04 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -141,6 +141,7 @@ class WebApplication : public WebView::EventListener { bool verbose_mode_; bool lang_changed_mode_; bool is_terminate_called_; + bool is_close_page_called_; Ewk_Context* ewk_context_; bool has_ownership_of_ewk_context_; NativeWindow* window_; -- 2.7.4 From d7b1a1caa77d6a1d56089a01e6b0930472bcfaec Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Wed, 18 Jan 2017 14:29:29 +0900 Subject: [PATCH 07/16] Refactor call of terminator The terminator has been registered by Runtime. It makes a dependency from WebApplication to Runtime and does not assure the existence of the Runtime instance. Bug: DF170116-01203 Url: http://suprem.sec.samsung.net/jira/browse/TWF-2805 Change-Id: I700bddab8fb392dca131ab5d3a913ed63e45b792 Signed-off-by: Youngsoo Choi --- runtime/browser/ui_runtime.cc | 3 --- runtime/browser/watch_runtime.cc | 1 - runtime/browser/web_application.cc | 26 ++++++++++++++++---------- runtime/browser/web_application.h | 4 ---- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/runtime/browser/ui_runtime.cc b/runtime/browser/ui_runtime.cc index 41fa8d9..7a6188f 100755 --- a/runtime/browser/ui_runtime.cc +++ b/runtime/browser/ui_runtime.cc @@ -107,10 +107,7 @@ void UiRuntime::ResetWebApplication(NativeWindow::Type windowType) { app_data_, context_)); LOGGER(DEBUG) << "runtime.cc created web application"; - application_->set_terminator([](){ ui_app_exit(); }); - LOGGER(DEBUG) << "runtime.cc ResetWebApplication() finished"; - STEP_PROFILE_END("Runtime ResetWebApplication"); } diff --git a/runtime/browser/watch_runtime.cc b/runtime/browser/watch_runtime.cc index f166e72..4ec298b 100644 --- a/runtime/browser/watch_runtime.cc +++ b/runtime/browser/watch_runtime.cc @@ -90,7 +90,6 @@ bool WatchRuntime::OnCreate() { STEP_PROFILE_START("WebApplication Create"); application_ = new WebApplication(native_window_, app_data_); STEP_PROFILE_END("WebApplication Create"); - application_->set_terminator([](){ watch_app_exit(); }); setlocale(LC_ALL, ""); bindtextdomain(kTextDomainRuntime, kTextLocalePath); diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index dd6383e..5ffaa5c 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -301,8 +301,7 @@ WebApplication::WebApplication( window_(window), appid_(app_data->app_id()), app_data_(app_data), - locale_manager_(new common::LocaleManager()), - terminator_(NULL) { + locale_manager_(new common::LocaleManager()) { Initialize(); } @@ -320,8 +319,7 @@ WebApplication::WebApplication( window_(window), appid_(app_data->app_id()), app_data_(app_data), - locale_manager_(new common::LocaleManager()), - terminator_(NULL) { + locale_manager_(new common::LocaleManager()) { Initialize(); } @@ -706,12 +704,20 @@ void WebApplication::Exit() { if (!is_terminate_called_) ecore_main_loop_quit(); - if (terminator_) { - LOGGER(DEBUG) << "terminator_"; - terminator_(); - } else { - LOGGER(ERROR) << "There's no registered terminator."; - elm_exit(); + switch (app_data_->app_type()) { + case common::ApplicationData::AppType::UI: + LOGGER(ERROR) << "app_ui_exit"; + ui_app_exit(); + break; +#ifdef WATCH_FACE_FEATURE_SUPPORT + case common::ApplicationData::AppType::WATCH: + LOGGER(ERROR) << "watch_ui_exit"; + watch_app_exit(); + break; +#endif + default: + LOGGER(ERROR) << "default terminator"; + elm_exit(); } } diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index f35fd04..20d9082 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -57,9 +57,6 @@ class WebApplication : public WebView::EventListener { void ProcessClosingPage(); std::string data_path() const { return app_data_path_; } - void set_terminator(std::function terminator) { - terminator_ = terminator; - } bool launched() const { return launched_; } std::list view_stack() const { return view_stack_; } @@ -152,7 +149,6 @@ class WebApplication : public WebView::EventListener { std::unique_ptr splash_screen_; std::unique_ptr locale_manager_; std::unique_ptr resource_manager_; - std::function terminator_; int security_model_version_; std::string csp_rule_; std::string csp_report_rule_; -- 2.7.4 From 915e46768613e6c1f1033b8e31efa73f343bee27 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Fri, 13 Jan 2017 16:07:21 +0900 Subject: [PATCH 08/16] Hide the window object during termination of webapp This white screen is shown because the webview is deleted and window object remains. This patch fixes this issue using evas_object_hide() API for preventing the white screen issue during the termination of web application. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2790 Change-Id: Ie697d4285d957ccc830518e78d3135c3770801c2 Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 5ffaa5c..6830891 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -793,6 +793,11 @@ void WebApplication::OnClosedWebView(WebView* view) { LOGGER(DEBUG) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; + + // Hide the window object for preventing the white screen + // during termination of web application. + evas_object_hide(window_->evas_object()); + session_counter.application = this; session_counter.timer = ecore_timer_add(SESSION_COUNTER_INTERVAL, CheckPluginSession, &session_counter); -- 2.7.4 From 25dd9a38d6f7f9464868846d0a17cd270f47b342 Mon Sep 17 00:00:00 2001 From: Srinivasarao Javvadi Date: Thu, 19 Jan 2017 13:14:12 +0530 Subject: [PATCH 09/16] Web app is not launching in user binary [Model] Pride Z250F [BinType] AP [Customer] N/A [Issue#] P170109-05747 [Request] N/A [Occurrence Version] [Problem] Window show & active are not being called [Cause & Measure] Cause: lang_changed_mode_ is not initialized in WebApplication object which is created using overloaded WebApplication constructor using Ewk_context. During frame rendered callback, window show & active will not be called upon language call back. Measure: Initialize lang_changed_mode_ to false in WebApplication object [Checking Method] Web application window should be shown on launching the app [Team] Web Run Time [Developer] Srinivasarao J [Solution company] Samsung [Change Type] N/A Change-Id: I0eb5acb7cafcee695bf8c6735baa6b41c1f6a91d --- runtime/browser/web_application.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 6830891..6c6688d 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -312,6 +312,7 @@ WebApplication::WebApplication( : launched_(false), debug_mode_(false), verbose_mode_(false), + lang_changed_mode_(false), is_terminate_called_(false), is_close_page_called_(false), ewk_context_(context), -- 2.7.4 From 28d7e3ffb4345e8e923c5e2e664db48c08baf30f Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Thu, 26 Jan 2017 15:21:07 +0900 Subject: [PATCH 10/16] Implement notification onclick event This CL enables notification onclick event. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2866 Change-Id: Iecb07daaacea6d82abc2824cabcc9941c33f70d1 Signed-off-by: Youngsoo Choi --- runtime/browser/notification_manager.cc | 37 +++++++++++++++++++++++++++++---- runtime/browser/notification_manager.h | 1 + 2 files changed, 34 insertions(+), 4 deletions(-) mode change 100644 => 100755 runtime/browser/notification_manager.h diff --git a/runtime/browser/notification_manager.cc b/runtime/browser/notification_manager.cc index aebd6e4..cff02ad 100755 --- a/runtime/browser/notification_manager.cc +++ b/runtime/browser/notification_manager.cc @@ -22,6 +22,7 @@ #include #include "common/logger.h" +#include "EWebKit_internal.h" namespace runtime { @@ -33,6 +34,26 @@ NotificationManager* NotificationManager::GetInstance() { NotificationManager::NotificationManager() { } +static void notification_onclick_event_cb( + notification_h noti, int event_type, void* userdata) { + NotificationManager* thiz = + static_cast(userdata); + int notification_priv_id = NOTIFICATION_PRIV_ID_NONE; + int ret = notification_get_id(noti, nullptr, ¬ification_priv_id); + if (ret != NOTIFICATION_ERROR_NONE) + LOGGER(ERROR) << "Can't get notification ID" << ret; + ewk_notification_clicked(thiz->FindNotificationID(notification_priv_id)); +} + +uint64_t NotificationManager::FindNotificationID( + int notification_priv_id) { + for (auto it = keymapper_.begin(); it != keymapper_.end(); it++) + if (it->second == notification_priv_id) + return it->first; + LOGGER(ERROR) << "Can't find notification ID" << notification_priv_id; + return 0; +} + bool NotificationManager::Show(uint64_t tag, const std::string& title, const std::string& body, @@ -93,13 +114,21 @@ bool NotificationManager::Show(uint64_t tag, } // insert notification - int platform_key = NOTIFICATION_PRIV_ID_NONE; - ret = notification_insert(noti_h, &platform_key); + ret = notification_post_with_event_cb( + noti_h, notification_onclick_event_cb, this); + if (ret != NOTIFICATION_ERROR_NONE) { + LOGGER(ERROR) << "Can't insert notification " << ret; + return false; + } + + int notification_priv_id = NOTIFICATION_PRIV_ID_NONE; + + ret = notification_get_id(noti_h, nullptr, ¬ification_priv_id); if (ret != NOTIFICATION_ERROR_NONE) { - LOGGER(ERROR) << "Can't insert notification"; + LOGGER(ERROR) << "Can't get notification ID" << ret; return false; } - keymapper_[tag] = platform_key; + keymapper_[tag] = notification_priv_id; return true; } diff --git a/runtime/browser/notification_manager.h b/runtime/browser/notification_manager.h old mode 100644 new mode 100755 index da93524..da703bc --- a/runtime/browser/notification_manager.h +++ b/runtime/browser/notification_manager.h @@ -30,6 +30,7 @@ class NotificationManager { const std::string& body, const std::string& icon_path); bool Hide(uint64_t tag); + uint64_t FindNotificationID(int notification_priv_id); private: NotificationManager(); std::map keymapper_; -- 2.7.4 From 3f570dca62b5d3dfe9f72ef598bc7951381adf2d Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Thu, 26 Jan 2017 15:32:15 +0900 Subject: [PATCH 11/16] Apply session counter only for product tv There hasn't been any issue on public profiles regarding session count. So, the session counter is not needed for the public profiles. Also this CL adds the codes for preventing white screen issue during the termination of web application. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2867 Change-Id: I2418669eb7000f57d56fdca27437a11e5d59d09b Signed-off-by: Youngsoo Choi Signed-off-by: Youngcheol Kang --- packaging/crosswalk-tizen.spec | 3 +++ runtime/browser/web_application.cc | 8 ++++++++ runtime/runtime.gyp | 3 +++ 3 files changed, 14 insertions(+) diff --git a/packaging/crosswalk-tizen.spec b/packaging/crosswalk-tizen.spec index b1f452b..e908515 100755 --- a/packaging/crosswalk-tizen.spec +++ b/packaging/crosswalk-tizen.spec @@ -115,6 +115,9 @@ GYP_OPTIONS="$GYP_OPTIONS -Dextension_path=%{extension_path}" # Injected bundle GYP_OPTIONS="$GYP_OPTIONS -Dinjected_bundle_path=%{injected_bundle_path}" +# Tizen product tv +GYP_OPTIONS="$GYP_OPTIONS -Dtizen_product_tv=%{!?TIZEN_PRODUCT_TV:0}" + # Build ./tools/gyp/gyp $GYP_OPTIONS xwalk_tizen.gyp ninja -C out/Default %{?_smp_mflags} diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 6c6688d..085af1e 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -758,6 +758,12 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { auto extension_server = XWalkExtensionServer::GetInstance(); LOGGER(DEBUG) << "Shutdown extension server"; extension_server->Shutdown(); +#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()); + Exit(); +#endif } else if (current != view_stack_.front()) { view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); @@ -792,6 +798,7 @@ void WebApplication::OnClosedWebView(WebView* view) { view->ReplyToJavascriptDialog(); RemoveWebViewFromStack(view); +#if defined(TIZEN_PRODUCT_TV) LOGGER(DEBUG) << "plugin_session_count : " << XWalkExtensionRendererController::plugin_session_count; @@ -804,6 +811,7 @@ void WebApplication::OnClosedWebView(WebView* view) { CheckPluginSession, &session_counter); if (!session_counter.timer) LOGGER(ERROR) << "It's failed to create session_counter timer"; +#endif } void WebApplication::OnReceivedWrtMessage(WebView* view, diff --git a/runtime/runtime.gyp b/runtime/runtime.gyp index a818470..4348b5f 100755 --- a/runtime/runtime.gyp +++ b/runtime/runtime.gyp @@ -76,6 +76,9 @@ ['profile == "tv"', { 'defines': ['PROFILE_TV'], }], + ['tizen_product_tv == "1"', { + 'defines': ['TIZEN_PRODUCT_TV'], + }], ['tizen_model_formfactor == "circle"', { 'defines': ['MODEL_FORMFACTOR_CIRCLE'], }], -- 2.7.4 From c332d2771236dd6c0b31483d35b3efea1346af9c Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Thu, 2 Feb 2017 10:17:27 +0900 Subject: [PATCH 12/16] fixup! Refactor call of terminator This patch fixes the following build problem in original patch. error: watch_app_exit was not declared in this scope watch_app_exit(); Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2906 Change-Id: Iaa9028fe0851a0fd8f93d29d779e92a1ef7a56e2 Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 1 + runtime/runtime.gyp | 1 + 2 files changed, 2 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 085af1e..f6efe80 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -17,6 +17,7 @@ #include "runtime/browser/web_application.h" #include +#include #include #include #include diff --git a/runtime/runtime.gyp b/runtime/runtime.gyp index 4348b5f..3f5ea2e 100755 --- a/runtime/runtime.gyp +++ b/runtime/runtime.gyp @@ -52,6 +52,7 @@ ], 'variables': { 'packages': [ + 'appcore-watch', 'capi-appfw-application', 'capi-ui-efl-util', 'chromium-efl', -- 2.7.4 From b56b1cfcb9d2aa23ca643643346d2965d2269c99 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Thu, 2 Feb 2017 11:41:25 +0900 Subject: [PATCH 13/16] fixup! fixup! Refactor call of terminator This patch fixes the following build problem in original patch. error : No package 'appcore-watch' found Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2906 Change-Id: I31ec4f3654f800944f2c3af8478f08d65c73d5fe Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 5 ++++- runtime/runtime.gyp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index f6efe80..ac93129 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -17,7 +17,6 @@ #include "runtime/browser/web_application.h" #include -#include #include #include #include @@ -29,6 +28,10 @@ #include #include +#ifdef WATCH_FACE_FEATURE_SUPPORT +#include +#endif + #include "common/application_data.h" #include "common/app_db.h" #include "common/app_control.h" diff --git a/runtime/runtime.gyp b/runtime/runtime.gyp index 3f5ea2e..4348b5f 100755 --- a/runtime/runtime.gyp +++ b/runtime/runtime.gyp @@ -52,7 +52,6 @@ ], 'variables': { 'packages': [ - 'appcore-watch', 'capi-appfw-application', 'capi-ui-efl-util', 'chromium-efl', -- 2.7.4 From fa25489141a3544101adfa8db98c275c505d13cd Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Mon, 6 Feb 2017 12:47:42 +0900 Subject: [PATCH 14/16] Add a code to check module_system To prevent decreasing "plugin_session_count", because the context is not created if it is a remote URL. Change-Id: I5a85ee2794bcb3b454ec937859435e62cd12d6ff Signed-off-by: jaekuk, lee --- extensions/renderer/xwalk_extension_renderer_controller.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/renderer/xwalk_extension_renderer_controller.cc b/extensions/renderer/xwalk_extension_renderer_controller.cc index 01c1ece..6c8dd11 100755 --- a/extensions/renderer/xwalk_extension_renderer_controller.cc +++ b/extensions/renderer/xwalk_extension_renderer_controller.cc @@ -91,9 +91,12 @@ void XWalkExtensionRendererController::DidCreateScriptContext( void XWalkExtensionRendererController::WillReleaseScriptContext( v8::Handle context) { v8::Context::Scope contextScope(context); + XWalkModuleSystem* module_system = XWalkModuleSystem::GetModuleSystemFromContext(context); + if (module_system) { + plugin_session_count--; + LOGGER(DEBUG) << "plugin_session_count : " << plugin_session_count; + } XWalkModuleSystem::ResetModuleSystemFromContext(context); - plugin_session_count--; - LOGGER(DEBUG) << "plugin_session_count : " << plugin_session_count; } void XWalkExtensionRendererController::OnReceivedIPCMessage( -- 2.7.4 From ab93561c683c7e1e58ca49d6be8d6640ff3dd58b Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 6 Feb 2017 13:09:15 +0900 Subject: [PATCH 15/16] Terminate properly when triggering hardware back key event Termination should not be done when there are multiple webviews and hardware back key event is triggered for page navigation. The termination needs to be done only if there is one webview on view stack. This CL adds condition for the checking webview count. PLM: P170125-05834 Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2951 Change-Id: I6d4056c46a0c9999d068d1dd4c14d4f4793457a0 Signed-off-by: Youngsoo Choi --- runtime/browser/web_application.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index ac93129..a99a876 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -931,8 +931,12 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { if(enabled) view->EvalJavascript(kBackKeyEventScript); if (!view->Backward()) { - LOGGER(DEBUG) << "Terminate"; - Terminate(); + if (view_stack_.size() == 1) { + LOGGER(DEBUG) << "Terminate"; + Terminate(); + } else { + RemoveWebViewFromStack(view_stack_.front()); + } } } return; @@ -947,8 +951,12 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { (app_data_->widget_info() != NULL && app_data_->widget_info()->view_modes() == "windowed")) { if (!view->Backward()) { - LOGGER(DEBUG) << "Terminate"; - Terminate(); + if (view_stack_.size() == 1) { + LOGGER(DEBUG) << "Terminate"; + Terminate(); + } else { + RemoveWebViewFromStack(view_stack_.front()); + } } } } else if (enabled && kKeyNameMenu == keyname) { -- 2.7.4 From f2afa7508b8bcbdbf23c0818b0be0c6b4b5ed548 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Tue, 20 Dec 2016 20:37:38 +0900 Subject: [PATCH 16/16] Fix for handling CSP behavior for backward compatibility with tizen 2.x WRT delivers the CSP elements of config.xml in web application to the webengine through ewk_view_content_security_policy_set API. However, some problem takes place in web application which doesn't set CSP element in config.xml. In order to resolve this compatibility problem, this patch adds the workaround codes for backward compatibility with tizen 2.x by request of webengine. In the webapp of tizen 2.x, this patch allows the all CSP policy by using "allow *;" element. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2689 Change-Id: Ifba3a8db7fa5a7ab984e9746ba8e3cbb7a901c10 Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index a99a876..0bb0383 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -455,7 +455,19 @@ bool WebApplication::Initialize() { security_model_version_ = 2; if (app_data_->csp_info() == NULL || app_data_->csp_info()->security_rules().empty()) { - csp_rule_ = kDefaultCSPRule; + // Add the workaround codes for backward compatibility with tizen 2.x + // by request of webengine. In the webapp of tizen 2.x, this patch allows + // the all CSP policy by using "allow *;" option. + if (app_data_->tizen_application_info() != NULL && + !app_data_->tizen_application_info()->required_version().empty()) { + std::string tizen_version = app_data_->tizen_application_info()->required_version(); + if (tizen_version[0] == '2') + csp_rule_ = "allow *;"; + else + csp_rule_ = kDefaultCSPRule; + } else { + csp_rule_ = kDefaultCSPRule; + } } else { csp_rule_ = app_data_->csp_info()->security_rules(); } -- 2.7.4