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

Node 的 setScale setPosition 等方法的性能问题 #16952

Closed
finscn opened this issue May 7, 2024 · 3 comments
Closed

Node 的 setScale setPosition 等方法的性能问题 #16952

finscn opened this issue May 7, 2024 · 3 comments
Assignees
Labels
Milestone

Comments

@finscn
Copy link
Contributor

finscn commented May 7, 2024

Cocos Creator version

3.8.2

System information

all

Issue description

对项目性能进行检测, 发现 setScale 居然成为性能热点之一.
查看源码发现, 3.8.x 里 不会 判断 设置的值和之前的值是否一样, 而是无脑更新 且会调用 invalidateChildren 深度遍历子节点.
以前 2.x 里 是会判断 新设置的值是否和之前不同.

建议 3.8 能加入类似机制.

Relevant error log output

No response

Steps to reproduce

Minimal reproduction project

No response

@finscn finscn added Bug Needs Triage Needs to be assigned by the team labels May 7, 2024
@minggo minggo self-assigned this May 8, 2024
@minggo minggo added this to the 3.8.5 milestone May 8, 2024
@minggo minggo removed the Needs Triage Needs to be assigned by the team label May 8, 2024
@minggo
Copy link
Contributor

minggo commented May 8, 2024

确实没想到这里会成为热点。你的项目为什么会频繁设置相同的值呢?

@finscn
Copy link
Contributor Author

finscn commented May 9, 2024

确实没想到这里会成为热点。你的项目为什么会频繁设置相同的值呢?

和玩法有关, 游戏里 的物体就是会经常的不断的缩放. 当然我可以自己判断, 只是我以为 3和2 一样 内部会判断呢.

@minggo
Copy link
Contributor

minggo commented May 9, 2024

引擎内部是应该做判断的。我会提交修改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants