Sometimes when the browser is lauching, browser is crash 04/80004/2
authorHye Kyoung Hwang <cookie@samsung.com>
Thu, 14 Jul 2016 05:24:47 +0000 (22:24 -0700)
committerHye Kyoung Hwang <cookie@samsung.com>
Thu, 14 Jul 2016 05:24:51 +0000 (22:24 -0700)
Revert "Async service loading and initialization"

This reverts commit 5de3a7d3982ebfcb88d05e74ee11c148c1457224.

Change-Id: Ie8dc592f99dc584b6340fa43f5622d92c3a81687

core/ServiceManager/ServiceLoader.cpp
core/ServiceManager/ServiceManager.cpp
services/SimpleUI/SimpleUI.cpp
services/SimpleUI/SimpleUI.h

index cbb5bec54fd3daa5a67c2f7b0c99edf75742ff69..51ea54fb78791f625e0b8ec4fc27fdfb1e3e0f5f 100644 (file)
@@ -44,6 +44,7 @@ void ServiceLoaderPrivate::loadService()
 ServiceLoader::ServiceLoader(const std::string& serviceFileName)
     : d(new ServiceLoaderPrivate(serviceFileName))
 {
+    BROWSER_LOGD( "%s %s", __PRETTY_FUNCTION__ , serviceFileName.c_str() );
 }
 
 
index 87f1b3bd5581520590c6ba226e68bc4db49649fe..09666e963055861973221a651fa8f502cab20bd3 100644 (file)
@@ -15,7 +15,6 @@
  */
 #include "browser_config.h"
 #include <unordered_map>
-#include <future>
 #include <boost/filesystem.hpp>
 #include "Config.h"
 #include "BrowserLogger.h"
@@ -31,6 +30,7 @@ ServiceManagerPrivate::ServiceManagerPrivate()
 {
     findServiceLibs();
     loadServiceLibs();
+    enumerateServices();
 }
 
 ServiceManagerPrivate::~ServiceManagerPrivate()
@@ -39,7 +39,6 @@ ServiceManagerPrivate::~ServiceManagerPrivate()
 void ServiceManagerPrivate::findServiceLibs()
 {
     try{
-        std::vector<std::future<void>> vt;
         boost::filesystem::path servicesDir(boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get("services/dir")));
         for( boost::filesystem::directory_iterator it(servicesDir);
                 it != boost::filesystem::directory_iterator();
@@ -49,22 +48,13 @@ void ServiceManagerPrivate::findServiceLibs()
                 if( (item.extension().string() == ".so" )
                     && (item.filename().string().find("lib") == 0)){
                     try{
-                        vt.push_back(
-                            std::async(
-                                std::launch::async,
-                                [this](boost::filesystem::path item){
-                                    servicesLoaderMap[item.string()] = std::shared_ptr<ServiceLoader>(new ServiceLoader(item.string()));
-                                },
-                            item)
-                        );
+                        servicesLoaderMap[item.string()] = std::shared_ptr<ServiceLoader>(new ServiceLoader(item.string()));
                     } catch (std::runtime_error & e){
                         BROWSER_LOGD(e.what() );
                     }
                 }
             }
         }
-        for(auto& th : vt)
-            th.get();
     } catch (const boost::filesystem::filesystem_error& ex){
         BROWSER_LOGD(ex.what() );
     }
@@ -94,6 +84,7 @@ void ServiceManagerPrivate::enumerateServices(){
 ServiceManager::ServiceManager()
     :d(new ServiceManagerPrivate)
 {
+
 }
 
 ServiceManager& ServiceManager::getInstance(void)
index f10a792a35d6ad7158f40a603ef10541bb584c8e..54d3b8d0a6d3424909c8289377ae4e04eddd1a7f 100644 (file)
@@ -235,132 +235,66 @@ void SimpleUI::restoreLastSession()
     }
 }
 
+
 //TODO: Move all service creation here:
 void SimpleUI::loadUIServices()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    std::vector<std::future<void>> ft;
 
-    ft.push_back(make_async_future([this](){
-        m_webPageUI =
+    m_webPageUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::WebPageUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webpageui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_quickAccess =
+        <tizen_browser::base_ui::WebPageUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webpageui"));
+
+    m_quickAccess =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::QuickAccess,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.quickaccess"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_tabUI =
+        <tizen_browser::base_ui::QuickAccess,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.quickaccess"));
+
+    m_tabUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::TabUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.tabui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_historyUI =
+        <tizen_browser::base_ui::TabUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.tabui"));
+
+    m_historyUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::HistoryUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_settingsUI =
+        <tizen_browser::base_ui::HistoryUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyui"));
+
+    m_settingsUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::SettingsUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.settingsui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_moreMenuUI =
+        <tizen_browser::base_ui::SettingsUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.settingsui"));
+
+    m_moreMenuUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::MoreMenuUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_bookmarkDetailsUI =
+        <tizen_browser::base_ui::MoreMenuUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.moremenuui"));
+
+    m_bookmarkDetailsUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::BookmarkDetailsUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkdetailsui"));
-    }));
-    #if PROFILE_MOBILE
-    ft.push_back(make_async_future([this](){
-        m_bookmarkFlowUI =
+        <tizen_browser::base_ui::BookmarkDetailsUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkdetailsui"));
+#if PROFILE_MOBILE
+    m_bookmarkFlowUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::BookmarkFlowUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkflowui"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_findOnPageUI =
+        <tizen_browser::base_ui::BookmarkFlowUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkflowui"));
+
+    m_findOnPageUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::FindOnPageUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.findonpageui"));
-    }));
+        <tizen_browser::base_ui::FindOnPageUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.findonpageui"));
 #else
-    ft.push_back(make_async_future([this](){
-        m_zoomUI =
+    m_zoomUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::ZoomUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.zoomui"));
-    }));
+        <tizen_browser::base_ui::ZoomUI, tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.zoomui"));
 #endif
-    ft.push_back(make_async_future([this](){
-        m_bookmarkManagerUI =
+    m_bookmarkManagerUI =
         std::dynamic_pointer_cast
-        <tizen_browser::base_ui::BookmarkManagerUI,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui"));
-    }));
-    for(auto& th : ft)
-        th.get();
-}
-
-void SimpleUI::loadModelServices()
-{
-    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    std::vector<std::future<void>> ft;
-    ft.push_back(make_async_future([this](){
-        m_webEngine =
-        std::dynamic_pointer_cast
-        <basic_webengine::AbstractWebEngine<Evas_Object>,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_storageService =
-        std::dynamic_pointer_cast
-        <tizen_browser::services::StorageService,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.storageservice"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_favoriteService =
-        std::dynamic_pointer_cast
-        <tizen_browser::interfaces::AbstractFavoriteService,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_historyService =
-        std::dynamic_pointer_cast
-        <tizen_browser::services::HistoryService,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyservice"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_tabService = std::dynamic_pointer_cast<
-        tizen_browser::services::TabService,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.tabservice"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_platformInputManager =
-        std::dynamic_pointer_cast
-        <tizen_browser::services::PlatformInputManager,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager"));
-    }));
-    ft.push_back(make_async_future([this](){
-        m_certificateContents =
-        std::dynamic_pointer_cast
-        <tizen_browser::services::CertificateContents,
-        tizen_browser::core::AbstractService>(tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.certificateservice"));
-    }));
-    for(auto& th : ft)
-        th.get();
+        <tizen_browser::base_ui::BookmarkManagerUI,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui"));
 }
 
 void SimpleUI::connectUISignals()
@@ -497,6 +431,47 @@ void SimpleUI::connectUISignals()
 #endif
 }
 
+void SimpleUI::loadModelServices()
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+
+    m_webEngine =
+        std::dynamic_pointer_cast
+        <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice"));
+
+    m_storageService =
+        std::dynamic_pointer_cast
+        <tizen_browser::services::StorageService,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.storageservice"));
+
+    m_favoriteService =
+        std::dynamic_pointer_cast
+        <tizen_browser::interfaces::AbstractFavoriteService,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice"));
+
+    m_historyService =
+        std::dynamic_pointer_cast
+        <tizen_browser::services::HistoryService,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.historyservice"));
+
+    m_tabService = std::dynamic_pointer_cast<
+            tizen_browser::services::TabService,
+            tizen_browser::core::AbstractService>(
+            tizen_browser::core::ServiceManager::getInstance().getService(
+                    "org.tizen.browser.tabservice"));
+
+    m_platformInputManager =
+        std::dynamic_pointer_cast
+        <tizen_browser::services::PlatformInputManager,tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager"));
+
+    m_certificateContents =
+        std::dynamic_pointer_cast
+        <tizen_browser::services::CertificateContents, tizen_browser::core::AbstractService>
+        (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.certificateservice"));
+}
+
 void SimpleUI::initUIServices()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
@@ -543,32 +518,28 @@ void SimpleUI::initUIServices()
     m_bookmarkManagerUI->setFoldersId(m_storageService->getFoldersStorage().AllFolder, m_storageService->getFoldersStorage().SpecialFolder);
 }
 
-std::future<void> SimpleUI::make_async_future(std::function<void()> f){
-    return std::async(std::launch::async, f);
-}
-
 void SimpleUI::initModelServices()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    std::vector<std::future<void>> ft;
-    M_ASSERT(m_webEngine.get());
-    M_ASSERT(m_webPageUI.get());
-    M_ASSERT(m_favoriteService.get());
-    M_ASSERT(m_platformInputManager.get());
-    M_ASSERT(m_certificateContents.get());
-#if PROFILE_MOBILE
-    M_ASSERT(m_storageService.get());
-#endif
-    ft.push_back(make_async_future([this](){m_webEngine->init(m_webPageUI->getContent());}));
-    ft.push_back(make_async_future([this](){m_favoriteService->getBookmarks();}));
-    ft.push_back(make_async_future([this](){m_platformInputManager->init(m_window.get());}));
-    ft.push_back(make_async_future([this](){m_certificateContents->init();}));
+
+    M_ASSERT(m_webEngine);
+    M_ASSERT(m_webPageUI->getContent());
+    m_webEngine->init(m_webPageUI->getContent());
 
 #if PROFILE_MOBILE
-    ft.push_back(make_async_future([this](){m_storageService->getSettingsStorage().initWebEngineSettingsFromDB();}));
+    M_ASSERT(m_storageService->getSettingsStorage());
+    M_ASSERT(m_storageService->getFoldersStorage());
+    m_storageService->getSettingsStorage().initWebEngineSettingsFromDB();
 #endif
-    for(auto& th : ft)
-        th.get();
+
+    M_ASSERT(m_favoriteService);
+    m_favoriteService->getBookmarks();
+
+    M_ASSERT(m_platformInputManager);
+    m_platformInputManager->init(m_window.get());
+
+    M_ASSERT(m_certificateContents.get());
+    m_certificateContents->init();
 }
 
 void SimpleUI::connectModelSignals()
index 9c7ccb690a083d54b8e95e8f7a05d184a1e362a7..7db348199d3a806a9ed3a55b476b0d54214a4828 100644 (file)
 #define SIMPLEUI_H_
 
 #include <Evas.h>
-#include <future>
-#include <functional>
+
 #include "AbstractMainWindow.h"
 #include "AbstractService.h"
 #include "AbstractFavoriteService.h"
 #include "ServiceFactory.h"
 #include "service_macros.h"
 
-
 // components
 #include "WebPageUI.h"
 #include "AbstractWebEngine.h"
@@ -125,7 +123,6 @@ private:
     void updateView();
     void windowCreated();
     void minimizeBrowser();
-    std::future<void> make_async_future(std::function<void()> f);
 
 #if PROFILE_MOBILE
     void openNewTab(const std::string &uri, const std::string& title =