Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
fb6f3e07
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fb6f3e07
编写于
11月 09, 2017
作者:
J
Jason Simmons
提交者:
GitHub
11月 09, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Log stack traces from exceptions thrown by calls from native into Java (#4346)
上级
f5bdf9b0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
7 deletion
+66
-7
fml/platform/android/jni_util.cc
fml/platform/android/jni_util.cc
+42
-0
fml/platform/android/jni_util.h
fml/platform/android/jni_util.h
+2
-0
shell/platform/android/platform_view_android_jni.cc
shell/platform/android/platform_view_android_jni.cc
+22
-7
未找到文件。
fml/platform/android/jni_util.cc
浏览文件 @
fb6f3e07
...
...
@@ -123,5 +123,47 @@ bool ClearException(JNIEnv* env) {
return
true
;
}
std
::
string
GetJavaExceptionInfo
(
JNIEnv
*
env
,
jthrowable
java_throwable
)
{
ScopedJavaLocalRef
<
jclass
>
throwable_clazz
(
env
,
env
->
FindClass
(
"java/lang/Throwable"
));
jmethodID
throwable_printstacktrace
=
env
->
GetMethodID
(
throwable_clazz
.
obj
(),
"printStackTrace"
,
"(Ljava/io/PrintStream;)V"
);
// Create an instance of ByteArrayOutputStream.
ScopedJavaLocalRef
<
jclass
>
bytearray_output_stream_clazz
(
env
,
env
->
FindClass
(
"java/io/ByteArrayOutputStream"
));
jmethodID
bytearray_output_stream_constructor
=
env
->
GetMethodID
(
bytearray_output_stream_clazz
.
obj
(),
"<init>"
,
"()V"
);
jmethodID
bytearray_output_stream_tostring
=
env
->
GetMethodID
(
bytearray_output_stream_clazz
.
obj
(),
"toString"
,
"()Ljava/lang/String;"
);
ScopedJavaLocalRef
<
jobject
>
bytearray_output_stream
(
env
,
env
->
NewObject
(
bytearray_output_stream_clazz
.
obj
(),
bytearray_output_stream_constructor
));
// Create an instance of PrintStream.
ScopedJavaLocalRef
<
jclass
>
printstream_clazz
(
env
,
env
->
FindClass
(
"java/io/PrintStream"
));
jmethodID
printstream_constructor
=
env
->
GetMethodID
(
printstream_clazz
.
obj
(),
"<init>"
,
"(Ljava/io/OutputStream;)V"
);
ScopedJavaLocalRef
<
jobject
>
printstream
(
env
,
env
->
NewObject
(
printstream_clazz
.
obj
(),
printstream_constructor
,
bytearray_output_stream
.
obj
()));
// Call Throwable.printStackTrace(PrintStream)
env
->
CallVoidMethod
(
java_throwable
,
throwable_printstacktrace
,
printstream
.
obj
());
// Call ByteArrayOutputStream.toString()
ScopedJavaLocalRef
<
jstring
>
exception_string
(
env
,
static_cast
<
jstring
>
(
env
->
CallObjectMethod
(
bytearray_output_stream
.
obj
(),
bytearray_output_stream_tostring
)));
if
(
ClearException
(
env
))
{
return
"Java OOM'd in exception handling, check logcat"
;
}
return
JavaStringToString
(
env
,
exception_string
.
obj
());
}
}
// namespace jni
}
// namespace fml
fml/platform/android/jni_util.h
浏览文件 @
fb6f3e07
...
...
@@ -36,6 +36,8 @@ bool HasException(JNIEnv* env);
bool
ClearException
(
JNIEnv
*
env
);
std
::
string
GetJavaExceptionInfo
(
JNIEnv
*
env
,
jthrowable
java_throwable
);
}
// namespace jni
}
// namespace fml
...
...
shell/platform/android/platform_view_android_jni.cc
浏览文件 @
fb6f3e07
...
...
@@ -18,6 +18,21 @@
namespace
shell
{
namespace
{
bool
CheckException
(
JNIEnv
*
env
)
{
if
(
env
->
ExceptionCheck
()
==
JNI_FALSE
)
return
true
;
jthrowable
exception
=
env
->
ExceptionOccurred
();
env
->
ExceptionClear
();
FXL_LOG
(
INFO
)
<<
fml
::
jni
::
GetJavaExceptionInfo
(
env
,
exception
);
env
->
DeleteLocalRef
(
exception
);
return
false
;
}
}
// anonymous namespace
static
fml
::
jni
::
ScopedJavaGlobalRef
<
jclass
>*
g_flutter_view_class
=
nullptr
;
static
fml
::
jni
::
ScopedJavaGlobalRef
<
jclass
>*
g_flutter_native_view_class
=
nullptr
;
...
...
@@ -33,7 +48,7 @@ void FlutterViewHandlePlatformMessage(JNIEnv* env,
jint
responseId
)
{
env
->
CallVoidMethod
(
obj
,
g_handle_platform_message_method
,
channel
,
message
,
responseId
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_handle_platform_message_response_method
=
nullptr
;
...
...
@@ -43,7 +58,7 @@ void FlutterViewHandlePlatformMessageResponse(JNIEnv* env,
jobject
response
)
{
env
->
CallVoidMethod
(
obj
,
g_handle_platform_message_response_method
,
responseId
,
response
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_update_semantics_method
=
nullptr
;
...
...
@@ -52,34 +67,34 @@ void FlutterViewUpdateSemantics(JNIEnv* env,
jobject
buffer
,
jobjectArray
strings
)
{
env
->
CallVoidMethod
(
obj
,
g_update_semantics_method
,
buffer
,
strings
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_on_first_frame_method
=
nullptr
;
void
FlutterViewOnFirstFrame
(
JNIEnv
*
env
,
jobject
obj
)
{
env
->
CallVoidMethod
(
obj
,
g_on_first_frame_method
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_attach_to_gl_context_method
=
nullptr
;
void
SurfaceTextureAttachToGLContext
(
JNIEnv
*
env
,
jobject
obj
,
jint
textureId
)
{
ASSERT_IS_GPU_THREAD
;
env
->
CallVoidMethod
(
obj
,
g_attach_to_gl_context_method
,
textureId
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_update_tex_image_method
=
nullptr
;
void
SurfaceTextureUpdateTexImage
(
JNIEnv
*
env
,
jobject
obj
)
{
ASSERT_IS_GPU_THREAD
;
env
->
CallVoidMethod
(
obj
,
g_update_tex_image_method
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
static
jmethodID
g_detach_from_gl_context_method
=
nullptr
;
void
SurfaceTextureDetachFromGLContext
(
JNIEnv
*
env
,
jobject
obj
)
{
ASSERT_IS_GPU_THREAD
;
env
->
CallVoidMethod
(
obj
,
g_detach_from_gl_context_method
);
FXL_CHECK
(
env
->
ExceptionCheck
()
==
JNI_FALSE
);
FXL_CHECK
(
CheckException
(
env
)
);
}
// Called By Java
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录