[HOTFIX] Delay main_loop shutdown to avoid deadlock 83/104983/5
authorws29.jung <ws29.jung@samsung.com>
Thu, 15 Dec 2016 05:20:22 +0000 (14:20 +0900)
committerws29.jung <ws29.jung@samsung.com>
Thu, 15 Dec 2016 10:39:41 +0000 (19:39 +0900)
When keyboard switches from Tizen Keyboard to WebApp Keyboard,
keyboard select button enables before WebApp keyboard is completely loaded.
In that time if keyboard switches back to Tizen Keyboard,
deadlock occurs between main_loop and Webview.
To avoid this deadlock, delay main_loop until webview load is finished

BUG: http://suprem.sec.samsung.net/jira/browse/TSAM-11361

Change-Id: I469bea8ff1b3dc3bbb69a37f0fe6114f30b8d855
Signed-off-by: ws29.jung <ws29.jung@samsung.com>
runtime/browser/runtime_process.cc

index 4d5cb50..b115546 100755 (executable)
 
 bool g_prelaunch = false;
 
+#ifdef IME_FEATURE_SUPPORT
+static Ecore_Timer* timeout = NULL;
+
+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;
@@ -132,8 +141,20 @@ int real_main(int argc, char* argv[]) {
     ret = runtime->Exec(argc, argv);
     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();
-  exit(ret);
+  elm_exit();
 
   return EXIT_SUCCESS;
 }