From 6ab249f220cf7dfd4bd19566023d4e261679de82 Mon Sep 17 00:00:00 2001 From: Dmitry Dushkin Date: Mon, 29 Apr 2019 03:29:04 -0700 Subject: [PATCH] Report native module name on crash when native module has failed to load (#24633) Summary: After upgrading RN from 0.57 to 0.59.4 we've received a lot of crash reports like `Exception in HostObject::get: ` with no clue what native module caused the crash. This commit adds native module name on crash in this situations. Related to https://github.com/facebook/react-native/issues/24607. [General] [Added] - Report native module name on crash when native module has failed to load Pull Request resolved: https://github.com/facebook/react-native/pull/24633 Differential Revision: D15120225 Pulled By: cpojer fbshipit-source-id: cf8e3e5953548a58f1d010eb70343da5ee946ae8 --- ReactCommon/jsi/JSCRuntime.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index 2129ee22d..eea027934 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -214,11 +214,11 @@ class JSCRuntime : public jsi::Runtime { static JSStringRef stringRef(const jsi::String& str); static JSStringRef stringRef(const jsi::PropNameID& sym); static JSObjectRef objectRef(const jsi::Object& obj); - + #ifdef RN_FABRIC_ENABLED static JSObjectRef objectRef(const jsi::WeakObject& obj); #endif - + // Factory methods for creating String/Object jsi::Symbol createSymbol(JSValueRef symbolRef) const; jsi::String createString(JSStringRef stringRef) const; @@ -688,7 +688,7 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr ho) { auto excValue = rt.global() .getPropertyAsFunction(rt, "Error") - .call(rt, "Exception in HostObject::get: "); + .call(rt, std::string("Exception in HostObject::get: ") + JSStringToSTLString(propertyName)); *exception = rt.valueRef(excValue); return JSValueMakeUndefined(ctx); } @@ -1359,14 +1359,14 @@ JSStringRef JSCRuntime::stringRef(const jsi::PropNameID& sym) { JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) { return static_cast(getPointerValue(obj))->obj_; } - + #ifdef RN_FABRIC_ENABLED JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) { // TODO: revisit this implementation return static_cast(getPointerValue(obj))->obj_; } #endif - + void JSCRuntime::checkException(JSValueRef exc) { if (JSC_UNLIKELY(exc)) { throw jsi::JSError(*this, createValue(exc));