Skip to content

Refactor MiddlewareManager::render to use updateOperateCache#80

Closed
finscn wants to merge 1 commit intococos:v4.0.0from
finscn:patch-5
Closed

Refactor MiddlewareManager::render to use updateOperateCache#80
finscn wants to merge 1 commit intococos:v4.0.0from
finscn:patch-5

Conversation

@finscn
Copy link
Copy Markdown

@finscn finscn commented Feb 12, 2026

Replaced the loop for erasing items from _updateList with a call to updateOperateCache.

之前的版本 , 只处理了 "移除对象" 的情况, 如果在 MiddlewareManager::update之后 MiddlewareManager::render 之前的游戏逻辑中, 有 把某个 spine对象设置为 enabled = true, 或者 羡 false 再true 的情况, 就不能被正确处理了.

Re: #

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.

Replaced the loop for erasing items from _updateList with a call to updateOperateCache.

之前的版本 , 只处理了 "移除对象" 的情况, 如果在  MiddlewareManager::update之后 MiddlewareManager::render 之前的游戏逻辑中, 有 把某个 spine对象设置为 enabled = true, 或者 羡 false 再true 的情况, 就不能被正确处理了.
@finscn
Copy link
Copy Markdown
Author

finscn commented Feb 13, 2026

附上两张 ai 的分析

image image image

MiddlewareManager::update() 的执行是在 所有组件的 updatePhase 之前, MiddlewareManager::render() 在之后.
所以 我在某一帧的某个组件的update方法里 里执行

spine.enabled = false
spine.enabled = true

那么在这一帧里, 不会渲染该spine对象, 因为 spine.enabled = true 没有被 MiddlewareManager::render () 处理.

@bofeng-song
Copy link
Copy Markdown
Contributor

@finscn 感谢反馈,目前的处理逻辑是在update之后的处理,延迟到下一帧。
render 执行完整的updateOperateCache, 可能会造成::update没执行,没有执行对应的渲染数据准备。直接提交渲染数据,这个时候数据是没有的。所以如果延迟一帧处理如果不影响效果。目前暂时不打算修改。

@finscn
Copy link
Copy Markdown
Author

finscn commented Feb 26, 2026

@finscn 感谢反馈,目前的处理逻辑是在update之后的处理,延迟到下一帧。 render 执行完整的updateOperateCache, 可能会造成::update没执行,没有执行对应的渲染数据准备。直接提交渲染数据,这个时候数据是没有的。所以如果延迟一帧处理如果不影响效果。目前暂时不打算修改。

会影响效果啊. spine会闪烁一下.

我们游戏里常见的一个场景是:
在同一帧里, 逻辑A 先执行, 逻辑 A 里觉得 spine需要隐藏, 于是 spine.enabled=false
然后再后续的逻辑 B 里, 经过更复杂和严格的判断后 觉得 spine不用隐藏, 于是又 spine.enabled=true
两个逻辑相对复杂和独立, 并不能合并成一个.

@bofeng-song
Copy link
Copy Markdown
Contributor

@finscn 可以参考下我的修复PR

@finscn
Copy link
Copy Markdown
Author

finscn commented Feb 28, 2026

@finscn 可以参考下我的修复PR

ok. 有修复就行. 希望尽快合并, 我好 merge 下.
我不太喜欢单独 手动合并某个 PR. 一个PR可能对应好几个 commit, 后面如果PR又变了 不好跟踪.

@bofeng-song
Copy link
Copy Markdown
Contributor

@finscn 可以参考下我的修复PR

这个合并了,麻烦验证下,没问题的话,后面会关闭该pr

@finscn
Copy link
Copy Markdown
Author

finscn commented Mar 8, 2026

@finscn 可以参考下我的修复PR

这个合并了,麻烦验证下,没问题的话,后面会关闭该pr

测试了 没问题

@finscn finscn closed this Mar 8, 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.

2 participants