Skip to content

Commit

Permalink
fix(ios): nullptr exception of engine resources in rare scenarios (#4046
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wwwcg authored Sep 24, 2024
1 parent be6ae6b commit 80c5b5d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions framework/ios/base/executors/HippyJSExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block {
return;
}
}
auto engine = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]->GetEngine();
std::shared_ptr<EngineResource> engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
if (!engineRsc) {
return;
}
auto engine = engineRsc->GetEngine();
if (engine) {
auto runner = engine->GetJsTaskRunner();
if (footstone::Worker::IsTaskRunning() && runner == footstone::runner::TaskRunner::GetCurrentTaskRunner()) {
Expand All @@ -679,7 +683,11 @@ - (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block {
return;
}
}
auto engine = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]->GetEngine();
std::shared_ptr<EngineResource> engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey];
if (!engineRsc) {
return;
}
auto engine = engineRsc->GetEngine();
if (engine) {
engine->GetJsTaskRunner()->PostTask(block);
}
Expand Down

0 comments on commit 80c5b5d

Please sign in to comment.