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

MouseJoint Touch Issue #18289

Open
wants to merge 1 commit into
base: v3.8.6
Choose a base branch
from
Open

MouseJoint Touch Issue #18289

wants to merge 1 commit into from

Conversation

gt3mb
Copy link

@gt3mb gt3mb commented Feb 7, 2025

This code ensures that all touch event listeners (TOUCH_START, TOUCH_MOVE, TOUCH_END, and TOUCH_CANCEL) attached to the Canvas node are properly removed when the MouseJoint component is destroyed.

Purpose:
Prevents touch event listeners from remaining in memory after the MouseJoint is destroyed. Avoids unexpected behavior caused by lingering event handlers that could still trigger interactions. Improves memory management and performance by ensuring proper cleanup of event listeners.

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.

This code ensures that all touch event listeners (TOUCH_START, TOUCH_MOVE, TOUCH_END, and TOUCH_CANCEL) attached to the Canvas node are properly removed when the MouseJoint component is destroyed.

Purpose:
Prevents touch event listeners from remaining in memory after the MouseJoint is destroyed.
Avoids unexpected behavior caused by lingering event handlers that could still trigger interactions.
Improves memory management and performance by ensuring proper cleanup of event listeners.
Copy link

github-actions bot commented Feb 7, 2025

⚠️ Package size ⤴ 316 bytes, old: 5208459, new: 5208775

Interface Check Report

This pull request does not change any public interfaces !

canvas.off(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
canvas.off(NodeEventType.TOUCH_END, this.onTouchEnd, this);
canvas.off(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think override destroy and disable them in destroy function is better as these listeners are enabled in initialize.

@dumganhar dumganhar closed this Feb 13, 2025
@dumganhar dumganhar reopened this Feb 13, 2025
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.

3 participants