Repository: incubator-weex Updated Branches: refs/heads/master ddc4f4bd0 -> 1a2ee1c93
[WEEX-360] [Android] Fix crash when reinit framework serializer will be freed after framework inited finished. So if we use it for re initialize. Will cause null ptr. Bug: WEEX-360 Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/1a2ee1c9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/1a2ee1c9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/1a2ee1c9 Branch: refs/heads/master Commit: 1a2ee1c93d4eade5821c986bb896faa074067da2 Parents: ddc4f4b Author: ä¸ç <yayun....@alibaba-inc.com> Authored: Mon May 14 16:17:16 2018 +0800 Committer: ä¸ç <yayun....@alibaba-inc.com> Committed: Mon May 14 16:17:16 2018 +0800 ---------------------------------------------------------------------- .../android/jsengine/multiprocess/WeexProxy.cpp | 57 ++++++++++---------- .../android/jsengine/multiprocess/WeexProxy.h | 4 +- 2 files changed, 31 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/1a2ee1c9/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp index 2d19683..da2f03f 100644 --- a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp +++ b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp @@ -122,7 +122,7 @@ namespace WeexCore { } jint - WeexProxy::initFrameworkInMultiProcess(JNIEnv *env, jstring script, IPCSerializer *serializer) { + WeexProxy::initFrameworkInMultiProcess(JNIEnv *env, jstring script, jobject params) { bool reinit = false; startInitFrameWork: try { @@ -139,13 +139,15 @@ namespace WeexCore { } } else { // initHandler(sHandler.get()); + ExtendJSApi *pExtensionJSApi = new ExtendJSApi(); pExtensionJSApi->initFunction(sHandler.get()); // using base::debug::TraceEvent; // TraceEvent::StartATrace(env); - + std::unique_ptr<IPCSerializer> serializer(createIPCSerializer()); + initFromParam(env, script, params, serializer.get()); serializer->setMsg(static_cast<uint32_t>(IPCJSMsg::INITFRAMEWORK)); std::unique_ptr<IPCBuffer> buffer = serializer->finish(); @@ -177,30 +179,27 @@ namespace WeexCore { jobject params) { Bridge_Impl_Android::getInstance()->setGlobalRef(jThis); - std::unique_ptr<IPCSerializer> serializer(createIPCSerializer()); - const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam(env, script, - params, - serializer.get()); - LOGE("doInitFramework is running"); - if (g_use_single_process) { - if (initFrameworkInSingleProcess(env, script, initFrameworkParams)) { - //reportNativeInitStatus("-1011", "init Single Process Success"); - return true; - } - - if (initFrameworkInMultiProcess(env, script, serializer.get())) { - return true; - } - } else { - if (initFrameworkInMultiProcess(env, script, serializer.get())) { - return true; - } - if (initFrameworkInSingleProcess(env, script, initFrameworkParams)) { - reportNativeInitStatus("-1011", "init Single Process Success"); - return true; - } + LOGE("doInitFramework is running"); +// if (g_use_single_process) { +// if (initFrameworkInSingleProcess(env, script, nullptr)) { +// //reportNativeInitStatus("-1011", "init Single Process Success"); +// return true; +// } +// +// if (initFrameworkInMultiProcess(env, script, params)) { +// return true; +// } +// } else { + if (initFrameworkInMultiProcess(env, script, params)) { + return true; } + +// if (initFrameworkInSingleProcess(env, script, nullptr)) { +// reportNativeInitStatus("-1011", "init Single Process Success"); +// return true; +// } +// } reportNativeInitStatus("-1010", "init Failed"); return false; @@ -462,9 +461,11 @@ namespace WeexCore { WEEX_CORE_JS_API_FUNCTIONS *functions); jint - WeexProxy::initFrameworkInSingleProcess(JNIEnv *env, jstring script, - std::vector<INIT_FRAMEWORK_PARAMS *> initFrameworkParams) { - + WeexProxy::initFrameworkInSingleProcess(JNIEnv *env, jstring script, jobject params) { + std::unique_ptr<IPCSerializer> serializer(createIPCSerializer()); + const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam(env, script, + params, + serializer.get()); std::string soPath = ""; // ----------------------------------------------- @@ -904,7 +905,7 @@ namespace WeexCore { if (js_server_api_functions != nullptr) { param = getValueWithTypePtr(); if (param == nullptr) - return false; + return nullptr; } jobject jArg = env->GetObjectArrayElement(jargs, i); http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/1a2ee1c9/weex_core/Source/android/jsengine/multiprocess/WeexProxy.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.h b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.h index 8c11bde..965ae48 100644 --- a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.h +++ b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.h @@ -53,8 +53,8 @@ public: initFromParam(JNIEnv *env, jstring script, jobject params, IPCSerializer *serializer); static jint - initFrameworkInSingleProcess(JNIEnv *env, jstring script, std::vector<INIT_FRAMEWORK_PARAMS *> initFrameworkParams); - static jint initFrameworkInMultiProcess(JNIEnv *env, jstring script, IPCSerializer *serializer); + initFrameworkInSingleProcess(JNIEnv *env, jstring script, jobject params); + static jint initFrameworkInMultiProcess(JNIEnv *env, jstring script, jobject params); static const char *getCacheDir(JNIEnv *env);