Skip to content

Commit

Permalink
fix(core): fix deadlock in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
churchill-zhang authored and zoomchan-cxj committed Mar 16, 2023
1 parent 76210a4 commit 4c772fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions android/sdk/src/main/jni/src/loader/adr_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ void OnResourceReady(JNIEnv* j_env,
TDF_BASE_DLOG(WARNING) << "HippyBridgeImpl onResourceReady, j_runtime_id invalid";
return;
}
std::weak_ptr<Scope> weak_scope = runtime->GetScope();
auto runner = runtime->GetEngine()->GetJSRunner();
auto runner = runtime->GetEngine()->GetWorkerTaskRunner();
if (!runner) {
return;
}
std::weak_ptr<Scope> weak_scope = runtime->GetScope();
int64_t request_id = j_request_id;
auto buffer = std::make_shared<JavaRef>(j_env, j_buffer);
auto task = std::make_unique<CommonTask>();
Expand Down Expand Up @@ -222,7 +222,7 @@ void OnResourceReady(JNIEnv* j_env,
cb(u8string());
return;
}
void* buff = j_env->GetDirectBufferAddress(j_buffer);
auto buff = j_env->GetDirectBufferAddress(j_buffer);
if (!buff) {
TDF_BASE_DLOG(INFO) << "HippyBridgeImpl onResourceReady, buff null";
cb(u8string());
Expand Down
2 changes: 1 addition & 1 deletion core/src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Engine::~Engine() {

void Engine::TerminateRunner() {
TDF_BASE_DLOG(INFO) << "~TerminateRunner";
js_runner_->Terminate();
worker_task_runner_->Terminate();
js_runner_->Terminate();
}

std::shared_ptr<Scope> Engine::CreateScope(const std::string& name,
Expand Down
13 changes: 5 additions & 8 deletions core/src/modules/contextify_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ void ContextifyModule::LoadUntrustedContent(const CallbackInfo& info) {
std::weak_ptr<Scope> weak_scope = scope;
std::weak_ptr<hippy::napi::CtxValue> weak_function = function;

std::function<void(u8string)> cb = [this, weak_scope, weak_function, encode,
uri](u8string code) {
std::shared_ptr<Scope> scope = weak_scope.lock();
std::function<void(u8string)> cb = [this, weak_scope, weak_function, encode, uri](u8string code) {
auto scope = weak_scope.lock();
if (!scope) {
return;
}
Expand All @@ -149,12 +148,10 @@ void ContextifyModule::LoadUntrustedContent(const CallbackInfo& info) {
<< ", encode = " << encode
<< ", code = " << unicode_string_view(code);
}
std::shared_ptr<JavaScriptTask> js_task =
std::make_shared<JavaScriptTask>();
auto js_task = std::make_shared<JavaScriptTask>();
js_task->callback = [this, weak_scope, weak_function,
move_code = std::move(code), cur_dir, file_name,
uri]() {
std::shared_ptr<Scope> scope = weak_scope.lock();
move_code = std::move(code), cur_dir, file_name, uri]() {
auto scope = weak_scope.lock();
if (!scope) {
return;
}
Expand Down

0 comments on commit 4c772fe

Please sign in to comment.