diff --git a/framework/ios/base/executors/HippyJSExecutor.mm b/framework/ios/base/executors/HippyJSExecutor.mm index 2bc0ab487f7..46c787d4cf3 100644 --- a/framework/ios/base/executors/HippyJSExecutor.mm +++ b/framework/ios/base/executors/HippyJSExecutor.mm @@ -661,7 +661,7 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block { return; } } - std::shared_ptr engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; + auto engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; if (!engineRsc) { return; } @@ -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); } } } @@ -683,13 +683,16 @@ - (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block { return; } } - std::shared_ptr 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); + } } } diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 5cfd1b514aa..b6750e43e87 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -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);