Skip to content

Prevent AssetsManagerEx destructor from clearing active static instance - #19191

Open
laipg91 wants to merge 2 commits into
cocos:v3.8.9from
laipg91:v3.8.9
Open

Prevent AssetsManagerEx destructor from clearing active static instance#19191
laipg91 wants to merge 2 commits into
cocos:v3.8.9from
laipg91:v3.8.9

Conversation

@laipg91

@laipg91 laipg91 commented Jul 17, 2026

Copy link
Copy Markdown

Re: #

Changelog

  • Prevent a potential race condition when multiple AssetsManagerEx instances are created sequentially.
  • Avoid clearing the active static assetsManager pointer when an older instance is destroyed.
  • Ensure native events continue to be dispatched to the current AssetsManagerEx instance during sequential hot updates.

Patch

AssetsManagerEx::~AssetsManagerEx()
{
-    assetsManager = nullptr;
+    if (assetsManager == this) {
+        assetsManager = nullptr;
+    }
}

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.

laipg91 added 2 commits July 7, 2026 10:46
…variable, the current instance will lost all callbacks
…race condition to static variable, the current instance will lost all callbacks

@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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@github-actions

Copy link
Copy Markdown

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1009838 bytes 1009838 bytes ✅ 0 bytes
2D All (legacy pipeline) 2675490 bytes 2675490 bytes ✅ 0 bytes
2D All (new pipeline) 2767226 bytes 2767226 bytes ✅ 0 bytes
(2D + 3D) All 10024224 bytes 10024224 bytes ✅ 0 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16843286 bytes 16843286 bytes ✅ 0 bytes

Interface Check Report

This pull request does not change any public interfaces !

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