You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by lu...@apache.org on 2019/08/15 02:22:43 UTC
[incubator-weex] branch master updated: [Android] Fix Android JNI
Crash (#2827)
This is an automated email from the ASF dual-hosted git repository.
luckychen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 7e54ac5 [Android] Fix Android JNI Crash (#2827)
7e54ac5 is described below
commit 7e54ac5c10bc93b8d72659d7dc9b5faa84753f5d
Author: YorkShen <sh...@gmail.com>
AuthorDate: Thu Aug 15 10:22:38 2019 +0800
[Android] Fix Android JNI Crash (#2827)
* [Android] Fix Android JNI Crash
`jni_object()` in `ReportException()` could be nullptr if `InitFramework()` is not invoked.
```
JNI DETECTED ERROR IN APPLICATION: obj == null
in call to CallVoidMethodV
from int com.taobao.weex.bridge.WXBridge.nativeCreateInstanceContext(java.lang.String, java.lang.String, java.lang.String, com.taobao.weex.bridge.WXJSObject[])
......
(_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+22)
(WeexCore::WXBridge::ReportException(_JNIEnv*, char const*, char const*, char const*)+132)
(WeexCore::AndroidSide::ReportException(char const*, char const*, char const*)+34)
......
(WeexCore::CoreSideInPlatform::CreateInstance(char const*, char const*, char const*, int, char const*, char const*, char const*, std::__ndk1::vector<InitFrameworkParams*, std::__ndk1::allocator<InitFrameworkParams*>>&, char const*)+820)
at com.taobao.weex.bridge.WXBridge.nativeCreateInstanceContext(Native method)
at com.taobao.weex.bridge.WXBridge.createInstanceContext(Taobao:233)
at com.taobao.weex.bridge.WXBridgeManager.invokeCreateInstanceContext(Taobao:1981)
at com.taobao.weex.bridge.WXBridgeManager.invokeCreateInstance(Taobao:1709)
```
* Fix crash in EagleBridge::WeexCoreHandler::PostTaskToMsgLoop
message_loop() in PostTaskToMsgLoop() could be nullptr if InitFramework() is not invoked.
* Avoid multiple initialization.
* Revert changes of InitSciptThread
* Post successCallback in RequestHandler to JSThread.
* Revert "Post successCallback in RequestHandler to JSThread."
This reverts commit 04bc4068
* Delete `;`
---
weex_core/Source/android/wrap/wx_bridge.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/weex_core/Source/android/wrap/wx_bridge.cpp b/weex_core/Source/android/wrap/wx_bridge.cpp
index e73bc12..53ec056 100755
--- a/weex_core/Source/android/wrap/wx_bridge.cpp
+++ b/weex_core/Source/android/wrap/wx_bridge.cpp
@@ -39,7 +39,6 @@
#include "base/android/jni_type.h"
#include "base/android/jni/jbytearray_ref.h"
#include "base/android/jniprebuild/jniheader/WXBridge_jni.h"
-#include "base/log_defines.h"
#include "core/config/core_environment.h"
#include "core/layout/layout.h"
#include "core/layout/measure_func_adapter_impl_android.h"
@@ -305,7 +304,9 @@ static void SetDeviceDisplay(JNIEnv* env, jobject jcaller, jstring instanceId,
static jint InitFramework(JNIEnv* env, jobject object, jstring script,
jobject params) {
- WXBridge::Instance()->Reset(env, object);
+ if (!WXBridge::Instance()->jni_object()) {
+ WXBridge::Instance()->Reset(env, object);
+ }
// Init platform thread --- ScriptThread
WeexCoreManager::Instance()->InitScriptThread();
// Exception handler for so
@@ -620,6 +621,9 @@ static jint CreateInstanceContext(JNIEnv* env, jobject jcaller,
// If strategy is DATA_RENDER_BINARY, jscript is a jbyteArray, otherwise jstring
// TODO use better way
+ if (!WXBridge::Instance()->jni_object()) {
+ WXBridge::Instance()->Reset(env, jcaller);
+ }
if (scoped_render_strategy.getChars() != nullptr
&& strcmp(scoped_render_strategy.getChars(), "DATA_RENDER_BINARY") == 0) {
JByteArrayRef byte_array(env, static_cast<jbyteArray>(jscript.Get()));