已合并
[render_service] Add null and error code checks for stability and remove deprecated API #31394
[render_service] Add null and error code checks for stability and remove deprecated API #31394
已合并
sunriseLL创建于 7月20日
sunriseLL
sunriseLL
7月20日

Description:

本 PR 提升渲染服务稳定性并清理废弃接口,主要包括:

  1. 空指针崩溃修复: RSRenderNode 多个方法在访问 stagingRenderParams_ 前未判空,新增 stagingRenderParams_ 空指针守卫,避免解引用 nullptr 崩溃。
  2. 错误码检查修复: RSRenderPipelineClient::CreateDisplayNodeCreateNode 新增 ErrCode 返回值检查,失败时打印 ROSEN_LOGE 日志并返回 false,改善 IPC 调用失败的可观测性。
  3. 废弃接口清理: 移除已无调用方的 RSSystemProperties::GetPrepareParallelRenderingEnabled,涵盖声明、ohos/darwin/windows 平台实现及对应 fuzz 桩、单测用例。

Issue number:

#24986

Test & Result:

  • 静态检查: git diff --check 通过,无尾空白/冲突标记。
  • 改动均为防御性判空与返回值检查,无新增对外接口或行为变更。
  • 缺少真实设备,未执行 XTS 与上板验证,需人工在设备上回归渲染服务主流程,确认 stagingRenderParams_ 判空路径与 IPC 错误码日志符合预期。

CodeCheck:

类型 自检项 自检结果
多线程 在类的成员变量中定义了vector/map/list等容器类型,且在多个成员函数中有操作时,需要加锁保护 不适用(本次改动未新增容器成员,仅加入空指针守卫与错误码检查,未改变容器访问方式)
定义全局变量,在多个函数中都有操作时,需要加锁保护 不适用(无新增全局变量)
内存操作 调用外部接口时,确认是否对返回值做了判空判断,尤其外部接口返回了nullptr的情况,避免进程崩溃 Pass(rs_render_node.cpp 新增 stagingRenderParams_ 空指针判断,避免解引用 nullptr 崩溃)
内存操作优先使用安全函数,并检查其返回值 Pass(rs_render_pipeline_client.cpp 新增 ErrCode 返回值检查,失败时记录日志并返回 false)
注意每个异常退出流程,是否都已经将资源释放(推荐使用RAII) Pass(异常路径均走 return,无新增需释放资源,RAII 保持)
隐式内存分配场景:realpath、ReadParcelable序列化、cJSON相关函数时等,需主动释放或使用智能指针 不适用(无 realpath/ReadParcelable/cJSON 调用)
外部输入 所有外部输入均不可信,需判断外部输入是否直接作为内存分配的大小,数组下标、循环条件、SQL查询等 不适用(无外部输入直接用作内存大小/下标/循环条件)
注意外部字符串数据有无尾0 不适用(无新增外部字符串处理)
外部输入的路径不可信,需使用realpath做标准化处理,并判断路径的合法性 不适用(无路径处理)
敏感信息 注意日志中打印敏感信息需匿名化 Pass(新增日志仅打印 ErrCode 整数,无敏感信息)
数学运算 代码中是否混合了加减乘除等运算,需检查是否可能导致整数溢出或符号翻转 不适用(无加减乘除运算)
初始化 类成员、局部变量使用前需初始化 Pass(success 初始化为 false,err 取返回值)
权限管理 作为系统服务对外提供了接口(或RSCmd),是否做了权限保护和校验,只允许申请了权限的应用访问 不适用(未新增对外接口/RSCmd,本次仅修改内部实现)

L0新增用例自检结果

likedislike
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 sunriseLL 的贡献)
sunriseLLsunriseLL
7月20日 关联了issue:[render_service] Add null and error code checks for stability and remove deprecated API
openharmony_ciopenharmony_ci成员
7月20日 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
7月20日 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
7月20日 添加了label:dco检查成功
sunriseLLsunriseLL
7月21日 审查状态已重置,审查人: xiaojianfeng_jeffery
此处折叠了115条消息 查看更多
openharmony_ciopenharmony_ci成员
7月25日 通过测试
openharmony_ciopenharmony_ci成员
7月25日 关闭了关联的issue
openharmony_ciopenharmony_ci成员
7月25日 合入了pull request,合并节点 SHA:8510708bc4c158733dbb4238cfc66c8d04a41a63
openharmony_ciopenharmony_ci成员
7月25日 删除了label:waiting_on_author
openharmony_ciopenharmony_ci成员
7月25日 添加了label:merged