!2707 merge crush into master

处理并发读写scbTokenMap_导致的crush问题

Created-by: chenrui_wza
Commit-by: chenrui_wza
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)



### 二、建议测试周期和提测地址  
  建议测试完成时间:xxxx.xx.xx  
  投产上线时间:xxxx.xx.xx  
  提测地址:CI环境/压测环境  
  测试账号:  

### 三、变更内容
  * 3.1 关联PR列表

  * 3.2 数据库和部署说明  
    1. 常规更新 
    2. 重启unicorn
    3. 重启sidekiq
    4. 迁移任务:是否有迁移任务,没有写 "无"
    5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无"

  * 3.4 其他技术优化内容(做了什么,变更了什么)
    - 重构了 xxxx 代码
    - xxxx 算法优化


  * 3.5 废弃通知(什么字段、方法弃用?)



  * 3.6  后向不兼容变更(是否有无法向后兼容的变更?)


  
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
  自测测试结论:


### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
  检查点:

| 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 |
|------|------------|----------|---------------|
| xxx  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:



See merge request: openharmony/accessibility!2707
This commit is contained in:
openharmony_ci
2026-08-08 12:20:38 +08:00
3 changed files with 6 additions and 8 deletions
@@ -20,10 +20,7 @@
#include "hilog_wrapper.h"
#include "ffrt.h"
#include "safe_map.h"
#include <unordered_set>
#include <atomic>
#include <unordered_set>
namespace OHOS {
namespace Accessibility {
@@ -132,7 +129,7 @@ private:
ffrt::mutex proxyMapMutex_;
std::unordered_map<uint64_t, std::pair<sptr<IAccessibilityElementOperator>, sptr<IRemoteObject::DeathRecipient>>>
proxyMap_;
std::unordered_set<uint32_t> scbTokenMap_;
SafeMap<uint32_t, bool> scbTokenMap_;
};
} // namespace Accessibility
} // namespace OHOS
@@ -95,7 +95,7 @@ RetError AccessibilityWindowConnection::SetTokenIdMap(const int32_t treeId,
if (windowId_ != SCENE_BOARD_WINDOW_ID) {
tokenIdMap_.EnsureInsert(treeId, tokenId);
} else {
scbTokenMap_.insert(tokenId);
scbTokenMap_.EnsureInsert(tokenId, true);
}
return RET_OK;
}
@@ -108,7 +108,7 @@ uint32_t AccessibilityWindowConnection::GetTokenIdMap(const int32_t treeId)
bool AccessibilityWindowConnection::CheckScbTokenIdMap(uint32_t tokenId)
{
return scbTokenMap_.count(tokenId) != 0;
return scbTokenMap_.ReadVal(tokenId);
}
void AccessibilityWindowConnection::GetAllTreeId(std::vector<int32_t> &treeIds)
@@ -182,9 +182,9 @@ void AccessibilityWindowConnection::ResetBrokerProxy()
bool AccessibilityWindowConnection::CheckScbTokenIdMap(uint32_t tokenId)
{
return scbTokenMap_.count(tokenId) != 0;
return scbTokenMap_.ReadVal(tokenId);
}
sptr<IAccessibilityElementOperator> AccessibilityWindowConnection::GetProxy(uint64_t displayId)
{
std::lock_guard<ffrt::mutex> lock(proxyMutex_);
@@ -197,6 +197,7 @@ sptr<IAccessibilityElementOperator> AccessibilityWindowConnection::GetProxy(uint
return proxyMap_[displayId].first;
}
}
sptr<IAccessibilityElementOperator> AccessibilityWindowConnection::GetRawProxy(uint64_t displayId)
{
std::lock_guard<ffrt::mutex> lock(proxyMutex_);