From 426f856c807da2d1eee8681f400567ee9e53b3e2 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Wed, 4 Sep 2024 17:24:34 +0800 Subject: [PATCH] fix(ios): null pointer exception of bridge setup in rare scenarios --- framework/ios/base/bridge/HippyBridge.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/ios/base/bridge/HippyBridge.mm b/framework/ios/base/bridge/HippyBridge.mm index fe6246a9d34..8a7d72e16d6 100644 --- a/framework/ios/base/bridge/HippyBridge.mm +++ b/framework/ios/base/bridge/HippyBridge.mm @@ -442,8 +442,9 @@ - (void)setUp { _javaScriptExecutor.contextCreatedBlock = ^(){ __strong __typeof(weakSelf)strongSelf = weakSelf; - if (strongSelf) { - dispatch_semaphore_wait(strongSelf.moduleSemaphore, DISPATCH_TIME_FOREVER); + dispatch_semaphore_t moduleSemaphore = strongSelf.moduleSemaphore; + if (strongSelf.isValid && moduleSemaphore) { + dispatch_semaphore_wait(moduleSemaphore, DISPATCH_TIME_FOREVER); NSDictionary *nativeModuleConfig = [strongSelf nativeModuleConfig]; [strongSelf.javaScriptExecutor injectObjectSync:nativeModuleConfig asGlobalObjectNamed:kHippyBatchedBridgeConfigKey callback:nil]; @@ -1085,7 +1086,6 @@ - (void)invalidate { _displayLink = nil; _moduleSetup = nil; _startTime = footstone::TimePoint::SystemNow(); - self.moduleSemaphore = nil; dispatch_group_notify(group, dispatch_get_main_queue(), ^{ [jsExecutor executeBlockOnJavaScriptQueue:^{