Skip to content

Commit

Permalink
fix(ios): thread race when getting uiManager
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Oct 30, 2024
1 parent 8e59529 commit 4b00876
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions renderer/native/ios/renderer/NativeRenderManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@
return;
}
HippyAssertParam(uiManager);
std::shared_lock<std::shared_mutex> lock(_mutex);
std::unique_lock<std::shared_mutex> lock(_mutex);
_uiManagerMap[rootNode->GetId()] = uiManager;
[uiManager registerRootView:view asRootNode:root_node];
}
}

void NativeRenderManager::UnregisterRootView(uint32_t rootId) {
@autoreleasepool {
std::shared_lock<std::shared_mutex> lock(_mutex);
std::unique_lock<std::shared_mutex> lock(_mutex);
HippyUIManager *uiManager = _uiManagerMap[rootId];
HippyAssertParam(uiManager);
[uiManager unregisterRootViewFromTag:@(rootId)];
Expand All @@ -275,7 +275,7 @@
}

NativeRenderManager::~NativeRenderManager() {
std::shared_lock<std::shared_mutex> lock(_mutex);
std::unique_lock<std::shared_mutex> lock(_mutex);
for (auto &pair : _uiManagerMap) {
[pair.second invalidate];
}
Expand Down

0 comments on commit 4b00876

Please sign in to comment.