Skip to content

Conversation

wang1212
Copy link
Member

@wang1212 wang1212 commented Sep 8, 2025

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

Problem Description:

In the current implementation, it is necessary to traverse the list of elements in the scene graph multiple times, which has an impact on performance, and the superposition effect of different events exacerbates the performance problem.

This pattern of traversing elements and triggering events is a bit like the early web standard MutationEvent, which has been deprecated and replaced by MutationObserve. It can be seen that this is an anti-pattern.

see https://developer.chrome.com/blog/mutation-events-deprecation

In addition, the performance problem of this implementation is obvious, so G uses the reuse mechanism of event objects to improve performance, but this approach has been proven to be insignificant. At the same time, we also conducted a simple test:

image

see facebook/react#18216

Solution:

The processing of internal element events is changed to batch triggering.

  • Create a list of elements only once
  • Events are only triggered on canvas instance (root element) only once
  • Event objects are no longer shared

Impact:

  • ElementEvent.BOUNDS_CHANGED (internal)

📝 Changelog

Language Changelog
🇺🇸 English perf: element event batch triggering
🇨🇳 Chinese perf: 批处理元素事件

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

changeset-bot bot commented Sep 8, 2025

⚠️ No Changeset found

Latest commit: 776071c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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