Add workload when oom

Issue: https://e.gitee.com/openharmony/issues/table?issue=IAU2J2

Signed-off-by: quiet-thought <chenjingxiang1@huawei.com>
Change-Id: I9fb50d508766a16f4239dc7535940eff8974c2e3
This commit is contained in:
quiet-thought 2024-09-27 17:06:35 +08:00
parent e4e8fa2cb6
commit ad510b912e

View File

@ -355,8 +355,16 @@ void ArkJSRuntime::ThrowError(const std::string& msg, int32_t code)
void ArkJSRuntime::RegisterUncaughtExceptionHandler(UncaughtExceptionCallback callback)
{
JSNApi::EnableUserUncaughtErrorHandler(vm_);
std::weak_ptr<ArkJSRuntime> weakThis = shared_from_this();
JSNApi::RegisterUncatchableErrorHandler(vm_,
std::bind(&ArkJSRuntime::HandleUncaughtExceptionWithoutNativeEngine, this, std::placeholders::_1, nullptr));
[weakThis](auto& tryCatch) {
auto sharedThis = weakThis.lock();
if (sharedThis) {
sharedThis->HandleUncaughtExceptionWithoutNativeEngine(tryCatch, nullptr);
} else {
LOGE("ArkJSRuntime has been destructed.");
}
});
uncaughtErrorHandler_ = callback;
}