Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIRenderManaer 的 UpdateAllRenders 函数存在数据漏处理 #16857

Open
vollen opened this issue Apr 2, 2024 · 0 comments
Open

UIRenderManaer 的 UpdateAllRenders 函数存在数据漏处理 #16857

vollen opened this issue Apr 2, 2024 · 0 comments
Assignees
Labels
Bug Needs Triage Needs to be assigned by the team
Milestone

Comments

@vollen
Copy link

vollen commented Apr 2, 2024

Cocos Creator version

3.8.1

System information

any

Issue description

真实使用场景,基于label的长度,动态设置背景的宽度。
//可复现问题的代码
private onLoad(){
this.titlelabel.node.on(Node.EventType.SIZE_CHANGED, () => {
this.onTextSizeChange()
});
}

private onTextSizeChange(){
    this.bg.node.transform.width = this.titlelabel.transform.width + 50
}

Bug 问题推演:

  1. 修改titlelabel的 string, 会让 label 进入 UIRenderManager 的 _dirtyRenderers
  2. UIRenderManager.updateAllDirtyRenderers() 会调用到 ttfUtils.updateRenderData
  3. 137 行更新 label node 的宽高,触发Node的EventType.SIZE_CHANGED事件。
  4. 游戏逻辑修改 bg 的宽度,会让 label 进入 UIRenderManager 的 _dirtyRenderers。
  5. 因为UIRenderManager.updateAllDirtyRenderers()遍历时记住了长度。所以 bg 的修改不会触发updateRenderData.
  6. updateAllDirtyRenderers函数退出时会清理_dirtyRenderers。
  7. 最终 bg 的这次宽度修改没有更新到渲染数据中去。

image

Relevant error log output

No response

Steps to reproduce

逻辑 bug

Minimal reproduction project

No response

@vollen vollen added Bug Needs Triage Needs to be assigned by the team labels Apr 2, 2024
@qiuguohua qiuguohua added this to the 3.8.4 milestone Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants