Skip to content

Canvas2D 的 getImageData 操作建议设置 willReadFrequently 属性为 true 以提高性能 - #19141

Closed
xbpiao wants to merge 1 commit into
cocos:v3.8.8from
xbpiao:v3.8.8_Canvas2D_set_willReadFrequently_true
Closed

Canvas2D 的 getImageData 操作建议设置 willReadFrequently 属性为 true 以提高性能#19141
xbpiao wants to merge 1 commit into
cocos:v3.8.8from
xbpiao:v3.8.8_Canvas2D_set_willReadFrequently_true

Conversation

@xbpiao

@xbpiao xbpiao commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

参考:https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

在 texture-cube.ts 文件中,当创建 Canvas2D 上下文时,没有设置 willReadFrequently 属性为 true,导致多次使用 getImageData 时性能较差。

Re: # 重现步骤:新建Hello World工程,使用Chrome版本 144.0.7559.110(正式版本) (64 位)预览发现错误

image

把错误扔给TRAE修复

image

修复后没有错误

d905d9f66c2015ad3dfbbbb35ab596c5

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1009738 bytes 1009762 bytes ⚠️ +24 bytes
2D All (legacy pipeline) 2675347 bytes 2675371 bytes ⚠️ +24 bytes
2D All (new pipeline) 2767083 bytes 2767107 bytes ⚠️ +24 bytes
(2D + 3D) All 10024081 bytes 10024105 bytes ⚠️ +24 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16843143 bytes 16843167 bytes ⚠️ +24 bytes

Interface Check Report

This pull request does not change any public interfaces !

@xbpiao

xbpiao commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author
image

不用这个天空盒子sunnySkyBox_reflection,只要Remove然后删除sunnySkyBox_reflection和sunnySkyBox_reflection_convolution就不会有这个警告了。

所以这个PR也没必要

@xbpiao xbpiao closed this Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant