Skip to content

Commit 2d3894f

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Don't crash when execute_method fails (#3104)
Summary: Currently, we hard crash the process when execute_method failed, and it's not catchable. Instead, we should return null to Java, so they can handle. Differential Revision: D56260831
1 parent 73438a5 commit 2d3894f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

extension/android/jni/jni_layer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,14 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
324324

325325
#endif
326326

327-
ET_CHECK_MSG(
328-
result.ok(),
329-
"Execution of method %s failed with status 0x%" PRIx32,
330-
method.c_str(),
331-
static_cast<error_code_t>(result.error()));
332-
ET_LOG(Info, "Model executed successfully.");
327+
if (!result.ok()) {
328+
ET_LOG(
329+
Error,
330+
"Execution of method %s failed with status 0x%" PRIx32,
331+
method.c_str(),
332+
static_cast<error_code_t>(result.error()));
333+
return {};
334+
}
333335

334336
facebook::jni::local_ref<facebook::jni::JArrayClass<JEValue>> jresult =
335337
facebook::jni::JArrayClass<JEValue>::newArray(result.get().size());

0 commit comments

Comments
 (0)