From 2125b52ce9dc12e49e4898445ccc97c06d21774e Mon Sep 17 00:00:00 2001 From: wwwcg Date: Wed, 30 Oct 2024 14:35:55 +0800 Subject: [PATCH] fix(ios): thread race when getting uiManager --- renderer/native/ios/renderer/NativeRenderManager.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/renderer/native/ios/renderer/NativeRenderManager.mm b/renderer/native/ios/renderer/NativeRenderManager.mm index d2402ec8d0c..916c55ae8e9 100644 --- a/renderer/native/ios/renderer/NativeRenderManager.mm +++ b/renderer/native/ios/renderer/NativeRenderManager.mm @@ -258,7 +258,7 @@ return; } HippyAssertParam(uiManager); - std::shared_lock lock(_mutex); + std::unique_lock lock(_mutex); _uiManagerMap[rootNode->GetId()] = uiManager; [uiManager registerRootView:view asRootNode:root_node]; } @@ -266,7 +266,7 @@ void NativeRenderManager::UnregisterRootView(uint32_t rootId) { @autoreleasepool { - std::shared_lock lock(_mutex); + std::unique_lock lock(_mutex); HippyUIManager *uiManager = _uiManagerMap[rootId]; HippyAssertParam(uiManager); [uiManager unregisterRootViewFromTag:@(rootId)]; @@ -275,7 +275,7 @@ } NativeRenderManager::~NativeRenderManager() { - std::shared_lock lock(_mutex); + std::unique_lock lock(_mutex); for (auto &pair : _uiManagerMap) { [pair.second invalidate]; }