Due to tizen_7.0 branch will not merge devel/master,
we should sync latest code style by our hands.
== This git commit is squash of below two patches ==
Revert "[Tizen][Web] Fix WebView terminate crash"
This reverts commit
52e86addc31a0b4393e8b7450e4b3c8a877f633d.
[Web] Fix WebView terminate crash
Due to the web context closed before all webview released,
mPlugin and mDestroyWebEnginePtr are invalid.
This patch make reference count so we can assume that
plugin is alive
Change-Id: Ia4a7f810c7aa02c3bd93c061ddb876debd6d4ad5
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/environment-variable.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/environment-variable.h>
-#include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-back-forward-list.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-back-forward-list.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
/**
* @brief Control the WebEnginePlugin library lifecycle.
/**
* @brief Control the WebEnginePlugin library lifecycle.
+ * Hold the plugin library handle in static singletone.
+ * It will makes library handle alives during all WebEngine resources create & destory.
*/
struct WebEnginePluginObject
{
public:
*/
struct WebEnginePluginObject
{
public:
- WebEnginePluginObject()
- : mPluginName{},
- mHandle{nullptr},
- mCreateWebEnginePtr{nullptr},
- mDestroyWebEnginePtr{nullptr},
- mGetWebEngineContextPtr{nullptr},
- mGetWebEngineCookieManagerPtr{nullptr}
+ static WebEnginePluginObject& GetInstance()
+ static WebEnginePluginObject gPluginHandle;
+ return gPluginHandle;
- ~WebEnginePluginObject()
+ /**
+ * @brief Converts an handle to a bool.
+ *
+ * This is useful for checking whether the WebEnginePluginObject succes to load library.
+ * @note We don't check mHandle because it is possible that mHandle load is success but
+ * Create/Destroy API load failed.
+ */
+ explicit operator bool() const
+ return mLoadSuccess;
+ }
+
+ bool InitializeContextHandle()
+ {
+ if(!mHandle)
- dlclose(mHandle);
- mHandle = nullptr;
+ return false;
+ }
+
+ if(!mGetWebEngineContextPtr)
+ {
+ mGetWebEngineContextPtr = reinterpret_cast<GetWebEngineContext>(dlsym(mHandle, "GetWebEngineContext"));
+
+ if(!mGetWebEngineContextPtr)
+ {
+ DALI_LOG_ERROR("Can't load symbol GetWebEngineContext(), error: %s\n", dlerror());
+ return false;
+ }
- bool InitializePluginHandle()
+ bool InitializeCookieManagerHandle()
- DALI_LOG_ERROR("Plugin.so has been opened already.\n");
- return true;
+ if(!mGetWebEngineCookieManagerPtr)
+ {
+ mGetWebEngineCookieManagerPtr = reinterpret_cast<GetWebEngineCookieManager>(dlsym(mHandle, "GetWebEngineCookieManager"));
+
+ if(!mGetWebEngineCookieManagerPtr)
+ {
+ DALI_LOG_ERROR("Can't load symbol GetWebEngineCookieManager(), error: %s\n", dlerror());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+private:
+ // Private constructor / destructor
+ WebEnginePluginObject()
+ : mPluginName{},
+ mLoadSuccess{false},
+ mHandle{nullptr},
+ mCreateWebEnginePtr{nullptr},
+ mDestroyWebEnginePtr{nullptr},
+ mGetWebEngineContextPtr{nullptr},
+ mGetWebEngineCookieManagerPtr{nullptr}
+ {
if(mPluginName.length() == 0)
{
// mPluginName is not initialized yet.
if(mPluginName.length() == 0)
{
// mPluginName is not initialized yet.
if(!mHandle)
{
DALI_LOG_ERROR("Can't load %s : %s\n", mPluginName.c_str(), dlerror());
if(!mHandle)
{
DALI_LOG_ERROR("Can't load %s : %s\n", mPluginName.c_str(), dlerror());
}
mCreateWebEnginePtr = reinterpret_cast<CreateWebEngineFunction>(dlsym(mHandle, "CreateWebEnginePlugin"));
if(mCreateWebEnginePtr == nullptr)
{
DALI_LOG_ERROR("Can't load symbol CreateWebEnginePlugin(), error: %s\n", dlerror());
}
mCreateWebEnginePtr = reinterpret_cast<CreateWebEngineFunction>(dlsym(mHandle, "CreateWebEnginePlugin"));
if(mCreateWebEnginePtr == nullptr)
{
DALI_LOG_ERROR("Can't load symbol CreateWebEnginePlugin(), error: %s\n", dlerror());
}
mDestroyWebEnginePtr = reinterpret_cast<DestroyWebEngineFunction>(dlsym(mHandle, "DestroyWebEnginePlugin"));
if(mDestroyWebEnginePtr == nullptr)
{
DALI_LOG_ERROR("Can't load symbol DestroyWebEnginePlugin(), error: %s\n", dlerror());
}
mDestroyWebEnginePtr = reinterpret_cast<DestroyWebEngineFunction>(dlsym(mHandle, "DestroyWebEnginePlugin"));
if(mDestroyWebEnginePtr == nullptr)
{
DALI_LOG_ERROR("Can't load symbol DestroyWebEnginePlugin(), error: %s\n", dlerror());
- return false;
- }
-
- return true;
- }
-
- bool InitializeContextHandle()
- {
- if(!InitializePluginHandle())
- {
- return false;
- }
-
- mGetWebEngineContextPtr = reinterpret_cast<GetWebEngineContext>(dlsym(mHandle, "GetWebEngineContext"));
-
- if(!mGetWebEngineContextPtr)
- {
- DALI_LOG_ERROR("Can't load symbol GetWebEngineContext(), error: %s\n", dlerror());
- return false;
- bool InitializeCookieManagerHandle()
+ ~WebEnginePluginObject()
- if(!InitializePluginHandle())
- {
- return false;
- }
-
- mGetWebEngineCookieManagerPtr = reinterpret_cast<GetWebEngineCookieManager>(dlsym(mHandle, "GetWebEngineCookieManager"));
-
- if(!mGetWebEngineCookieManagerPtr)
- DALI_LOG_ERROR("Can't load symbol GetWebEngineCookieManager(), error: %s\n", dlerror());
- return false;
+ dlclose(mHandle);
+ mHandle = nullptr;
+ mLoadSuccess = false;
WebEnginePluginObject(const WebEnginePluginObject&) = delete;
WebEnginePluginObject(WebEnginePluginObject&&) = delete;
WebEnginePluginObject& operator=(const WebEnginePluginObject&) = delete;
WebEnginePluginObject(const WebEnginePluginObject&) = delete;
WebEnginePluginObject(WebEnginePluginObject&&) = delete;
WebEnginePluginObject& operator=(const WebEnginePluginObject&) = delete;
/// Note: Dali WebView policy does not allow to use multiple web engines in an application.
/// So once pluginName is set to non-empty string, it will not change.
/// Note: Dali WebView policy does not allow to use multiple web engines in an application.
/// So once pluginName is set to non-empty string, it will not change.
+ bool mLoadSuccess; ///< True if library loaded successfully. False otherwise.
+
public:
using CreateWebEngineFunction = Dali::WebEnginePlugin* (*)();
using DestroyWebEngineFunction = void (*)(Dali::WebEnginePlugin* plugin);
public:
using CreateWebEngineFunction = Dali::WebEnginePlugin* (*)();
using DestroyWebEngineFunction = void (*)(Dali::WebEnginePlugin* plugin);
GetWebEngineCookieManager mGetWebEngineCookieManagerPtr; ///< Function to get WebEngineCookieManager
};
GetWebEngineCookieManager mGetWebEngineCookieManagerPtr; ///< Function to get WebEngineCookieManager
};
-static WebEnginePluginObject gPluginHandle; // Keep this object as static, so Let we assume that library closed after all WebEngines are disposed.
-
} // unnamed namespace
WebEnginePtr WebEngine::New()
} // unnamed namespace
WebEnginePtr WebEngine::New()
Dali::WebEngineContext* WebEngine::GetContext()
{
Dali::WebEngineContext* WebEngine::GetContext()
{
- if(!gPluginHandle.InitializeContextHandle())
+ if(!WebEnginePluginObject::GetInstance().InitializeContextHandle())
- if(gPluginHandle.mGetWebEngineContextPtr)
+ if(WebEnginePluginObject::GetInstance().mGetWebEngineContextPtr)
- return gPluginHandle.mGetWebEngineContextPtr();
+ return WebEnginePluginObject::GetInstance().mGetWebEngineContextPtr();
Dali::WebEngineCookieManager* WebEngine::GetCookieManager()
{
Dali::WebEngineCookieManager* WebEngine::GetCookieManager()
{
- if(!gPluginHandle.InitializeCookieManagerHandle())
+ if(!WebEnginePluginObject::GetInstance().InitializeCookieManagerHandle())
- if(gPluginHandle.mGetWebEngineCookieManagerPtr)
+ if(WebEnginePluginObject::GetInstance().mGetWebEngineCookieManagerPtr)
- return gPluginHandle.mGetWebEngineCookieManagerPtr();
+ return WebEnginePluginObject::GetInstance().mGetWebEngineCookieManagerPtr();
if(mPlugin != nullptr)
{
mPlugin->Destroy();
if(mPlugin != nullptr)
{
mPlugin->Destroy();
- if(gPluginHandle.mDestroyWebEnginePtr != nullptr)
+ // Check whether plugin load sccess or not.
+ if(DALI_LIKELY(WebEnginePluginObject::GetInstance()))
- gPluginHandle.mDestroyWebEnginePtr(mPlugin);
+ WebEnginePluginObject::GetInstance().mDestroyWebEnginePtr(mPlugin);
bool WebEngine::Initialize()
{
bool WebEngine::Initialize()
{
- if(!gPluginHandle.InitializePluginHandle())
+ // Check whether plugin load sccess or not.
+ if(!WebEnginePluginObject::GetInstance())
- mPlugin = gPluginHandle.mCreateWebEnginePtr();
+ mPlugin = WebEnginePluginObject::GetInstance().mCreateWebEnginePtr();
if(mPlugin == nullptr)
{
DALI_LOG_ERROR("Can't create the WebEnginePlugin object\n");
if(mPlugin == nullptr)
{
DALI_LOG_ERROR("Can't create the WebEnginePlugin object\n");