From 69a43a53ef090e1c70ab8969c420073c14caf21a Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 22 Nov 2016 12:57:02 +0900 Subject: [PATCH] preload native libraries and pre-create windows to optimize app launching performance Change-Id: Ia9065c5b2a1470aa3c72675b7bb953bd4bf00dc1 Signed-off-by: Cho Woong Suk --- NativeLauncher/CMakeLists.txt | 2 +- NativeLauncher/dotnet.loader | 10 +++++ NativeLauncher/launcher/launcher.cc | 73 ++++++++++++++++++++++++++++++++++++- packaging/dotnet-launcher.spec | 1 + 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index cd273e1..3c35c5f 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -7,7 +7,7 @@ IF(DEFINED NO_TIZEN) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNO_TIZEN") ELSE(DEFINED NO_TIZEN) INCLUDE(FindPkgConfig) - PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad) + PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary) ENDIF(DEFINED NO_TIZEN) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) diff --git a/NativeLauncher/dotnet.loader b/NativeLauncher/dotnet.loader index 67094b9..57b547d 100644 --- a/NativeLauncher/dotnet.loader +++ b/NativeLauncher/dotnet.loader @@ -4,3 +4,13 @@ EXE /usr/bin/dotnet-launcher APP_TYPE dotnet DETECTION_METHOD TIMEOUT|DEMAND TIMEOUT 5000 +EXTRA_ARRAY preload +EXTRA_ARRAY_VAL /usr/lib/libappcore-efl.so.1 +EXTRA_ARRAY_VAL /usr/lib/libappcore-common.so.1 +EXTRA_ARRAY_VAL /usr/lib/libcapi-appfw-application.so.0 +EXTRA_ARRAY_VAL /usr/lib/ecore_imf/modules/wayland/v-1.16/libwltextinputmodule.so +EXTRA_ARRAY_VAL /usr/lib/libdali-toolkit.so +EXTRA_ARRAY_VAL /usr/lib/libcairo.so.2 +EXTRA_ARRAY_VAL /usr/lib/libefl-assist.so.0 +EXTRA_ARRAY_VAL /usr/lib/libcapi-media-player.so.0 +EXTRA_ARRAY_VAL /usr/lib/libcapi-media-camera.so.0 diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index ebbc58d..c26b0e0 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -21,12 +21,15 @@ #include #include +#include +#include #include #include #include #include +#include namespace tizen { @@ -38,6 +41,12 @@ struct FdHandler loader_receiver_cb receiver; }; +static int __argc; +static char **__argv; +static Evas_Object *__win; +static Evas_Object *__bg; +static Evas_Object *__conform; + class LaunchpadAdapterImpl : public LaunchpadAdapter { public: @@ -124,12 +133,74 @@ static void Fd_Remove(void *data, int fd) } } -void LaunchpadAdapterImpl::LoaderMain(int argc, char* argv[]) + +static void PreloadLibsAndWindow(bundle *extra, int type, void *user_data) { + int elm_init_cnt = 0; + const char **so_array; + int len = 0; + int i; + void *handle = NULL; + + // Preload native libraries + if (extra == NULL) { + _DBG("No extra data"); + return; + } + + so_array = bundle_get_str_array(extra, "preload", &len); + if (!so_array) + return; + + for (i = 0; i < len; i++) { + handle = dlopen(so_array[i], RTLD_NOW); + _DBG("preload %s# - handle : %x\n", so_array[i], handle); + } + + // Precreate window + elm_init_cnt = elm_init(__argc, __argv); + _DBG("[candidate] elm init, returned: %d", elm_init_cnt); + + elm_config_accel_preference_set("hw"); + + __win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC); + if (__win == NULL) { + _DBG("[candidate] elm_win_add() failed"); + return; + } + + elm_win_precreated_object_set(__win); + + __bg = elm_bg_add(__win); + if (__bg) { + evas_object_size_hint_weight_set(__bg, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_win_resize_object_add(__win, __bg); + elm_bg_precreated_object_set(__bg); + } else { + _DBG("[candidate] elm_bg_add() failed"); + } + + __conform = elm_conformant_add(__win); + if (__conform) { + evas_object_size_hint_weight_set(__conform, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_win_resize_object_add(__win, __conform); + elm_conformant_precreated_object_set(__conform); + } else { + _DBG("elm_conformant_add() failed"); + } +} + +void LaunchpadAdapterImpl::LoaderMain(int argc, char* argv[]) +{ + __argc = argc; + __argv = argv; callbacks.create = [](bundle *extra, int type, void *user_data) { ecore_init(); + PreloadLibsAndWindow(extra, type, user_data); WITH_SELF(user_data) { if (self->OnCreate != nullptr) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 0a95375..87cef0e 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -17,6 +17,7 @@ BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(launchpad) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(pkgmgr-installer) +BuildRequires: pkgconfig(elementary) BuildRequires: aul-devel BuildRequires: mono-compiler BuildRequires: mono-devel -- 2.7.4