Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): add nullptr exception protection in rare scenarios #4055

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions framework/ios/base/executors/HippyJSExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block {
return;
}
}
std::shared_ptr<EngineResource> engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
auto engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
if (!engineRsc) {
return;
}
Expand All @@ -670,8 +670,8 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block {
auto runner = engine->GetJsTaskRunner();
if (footstone::Worker::IsTaskRunning() && runner == footstone::runner::TaskRunner::GetCurrentTaskRunner()) {
block();
} else {
engine->GetJsTaskRunner()->PostTask(block);
} else if (runner) {
runner->PostTask(block);
}
}
}
Expand All @@ -683,13 +683,16 @@ - (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block {
return;
}
}
std::shared_ptr<EngineResource> engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
auto engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
if (!engineRsc) {
return;
}
auto engine = engineRsc->GetEngine();
if (engine) {
engine->GetJsTaskRunner()->PostTask(block);
auto runner = engine->GetJsTaskRunner();
if (runner) {
runner->PostTask(block);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion renderer/native/ios/renderer/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ - (void)addEventName:(const std::string &)name
if (!bridge) {
return;
}
[bridge.javaScriptExecutor executeBlockOnJavaScriptQueue:^{
[bridge.javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{
auto strongNode = weakNode.lock();
if (strongNode) {
strongNode->HandleEvent(event);
Expand Down
Loading