Skip to content

Commit

Permalink
fix(ios): add nullptr exception protection in rare scenarios (#4055)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Oct 11, 2024
1 parent 0336c26 commit cb8c334
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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

0 comments on commit cb8c334

Please sign in to comment.