mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 09:45:04 +00:00
Try/catch exceptions in JSCExecutor for debugging crash
Reviewed By: lexs Differential Revision: D2982534 fb-gh-sync-id: 4eda4116cd60e2e46771ecddefc1d27eee761762 shipit-source-id: 4eda4116cd60e2e46771ecddefc1d27eee761762
This commit is contained in:
parent
4b98511a3e
commit
f99579adaa
@ -126,13 +126,17 @@ JSCExecutor::JSCExecutor(
|
||||
}
|
||||
|
||||
JSCExecutor::~JSCExecutor() {
|
||||
*m_isDestroyed = true;
|
||||
if (m_messageQueueThread->isOnThread()) {
|
||||
terminateOnJSVMThread();
|
||||
} else {
|
||||
m_messageQueueThread->runOnQueueSync([this] () {
|
||||
try {
|
||||
*m_isDestroyed = true;
|
||||
if (m_messageQueueThread->isOnThread()) {
|
||||
terminateOnJSVMThread();
|
||||
});
|
||||
} else {
|
||||
m_messageQueueThread->runOnQueueSync([this] () {
|
||||
terminateOnJSVMThread();
|
||||
});
|
||||
}
|
||||
} catch (...) {
|
||||
Exceptions::handleUncaughtException();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,14 @@ LoadScriptFromAssets loadScriptFromAssets;
|
||||
|
||||
namespace PerfLogging {
|
||||
InstallNativeHooks installNativeHooks;
|
||||
}
|
||||
};
|
||||
|
||||
namespace JSLogging {
|
||||
JSCNativeHook nativeHook = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
namespace Exceptions {
|
||||
HandleUncaughtException handleUncaughtException;
|
||||
};
|
||||
|
||||
} }
|
||||
|
@ -34,7 +34,7 @@ extern LoadScriptFromAssets loadScriptFromAssets;
|
||||
namespace PerfLogging {
|
||||
using InstallNativeHooks = std::function<void(JSGlobalContextRef)>;
|
||||
extern InstallNativeHooks installNativeHooks;
|
||||
}
|
||||
};
|
||||
|
||||
namespace JSLogging {
|
||||
using JSCNativeHook = JSValueRef (*) (
|
||||
@ -44,6 +44,11 @@ namespace JSLogging {
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[], JSValueRef *exception);
|
||||
extern JSCNativeHook nativeHook;
|
||||
}
|
||||
};
|
||||
|
||||
namespace Exceptions {
|
||||
using HandleUncaughtException = std::function<void()>;
|
||||
extern HandleUncaughtException handleUncaughtException;
|
||||
};
|
||||
|
||||
} }
|
||||
|
@ -865,6 +865,9 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
return std::unique_ptr<MessageQueueThread>(
|
||||
JMessageQueueThread::currentMessageQueueThread().release());
|
||||
};
|
||||
Exceptions::handleUncaughtException = [] () {
|
||||
translatePendingCppExceptionToJavaException();
|
||||
};
|
||||
PerfLogging::installNativeHooks = addNativePerfLoggingHooks;
|
||||
JSLogging::nativeHook = nativeLoggingHook;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user