Skip to content

fix(ui):keep destroy widgets out of the widget's active list - #302

Merged
llsansun merged 1 commit into
cocos:v4.0.0from
LinYunMo:v4.0.0
Aug 21, 2026
Merged

fix(ui):keep destroy widgets out of the widget's active list#302
llsansun merged 1 commit into
cocos:v4.0.0from
LinYunMo:v4.0.0

Conversation

@LinYunMo

Copy link
Copy Markdown
Contributor

Re: cocos/cocos-engine#18893

Changelog

  • activeWidgets could keep widgets that have already been destroyed, so
    refreshScene called align() with widget.node === null (reset by
    CCObject._destruct) and threw every frame.
    Entries got in through visitNode, which collected widgets by widget.enabled
    alone - a flag that stays true after destroy(). Entries only got out through
    Widget.onDisable, which disableComp skips unless the component was enabled
    by the scheduler (IsOnEnableCalled).
    • visitNode now rejects widgets that are already marked for destruction.
    • Widget.onDestroy unregisters as well, covering widgets that were collected
      while still valid but never got onDisable.

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.

@LinYunMo
LinYunMo requested a review from llsansun August 20, 2026 10:12
@github-actions

Copy link
Copy Markdown

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1015435 bytes 1015435 bytes ✅ 0 bytes
2D All (legacy pipeline) 2683166 bytes 2683232 bytes ⚠️ +66 bytes
2D All (new pipeline) 2775425 bytes 2775491 bytes ⚠️ +66 bytes
(2D + 3D) All 10032867 bytes 10032933 bytes ⚠️ +66 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16869285 bytes 16869351 bytes ⚠️ +66 bytes

Interface Check Report

This pull request does not change any public interfaces !

@github-actions

Copy link
Copy Markdown

@LinYunMo, Please check the result of run test cases:

Task Details

@github-actions

Copy link
Copy Markdown

@LinYunMo, Please check the result of run test cases:

Task Details

@llsansun
llsansun merged commit 609512f into cocos:v4.0.0 Aug 21, 2026
15 checks passed
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